Comments (6)
I'm sorry, the event name
JsonApiEvent
was wrong. The correct name isOnJsonApiEvent
.-ws.onopen = () => ws.send(JSON.stringify([5, 'JsonApiEvent'])) +ws.onopen = () => ws.send(JSON.stringify([5, 'OnJsonApiEvent']))
Yay, it works <3 Thank you man
from penguloader.
You should subscribe to LCU websocket to detect it.
Please refer to LCU Websocket in README to do that in your plugin.
Here is an API to get the current phase.
GET /lol-gameflow/v1/gameflow-phase
The "ReadyCheck" result means ready to accept matchmaking found.
And "ChampSelect" means you're in champ-select phase.
from penguloader.
You should subscribe to LCU websocket to detect it. Please refer to LCU Websocket in README to do that in your plugin.
Here is an API to get the current phase.
GET /lol-gameflow/v1/gameflow-phase
The "ReadyCheck" result means ready to accept matchmaking found. And "ChampSelect" means you're in champ-select phase.
I managed to send the GET request and it worked. So I think I should send a GET Request every 1 second to detect whenever I get into a champ select.
Lastly I would need to know when someone send a message, if you have any idea
from penguloader.
You should subscribe to LCU websocket to detect it.
Please refer to LCU Websocket in README to do that in your plugin.
This will solve your problem.
In my comment above, you no need to call this API every seconds.
The websocket's onmessage callback will give you which API is called and its data.
ws.onmessage = async message => {
const data = JSON.parse(message.data)
console.log(data)
const api = /* extract the data to get API */
if (api === '/lol-gameflow/v1/gameflow-phase') {
// todo
}
}
from penguloader.
You should subscribe to LCU websocket to detect it.
Please refer to LCU Websocket in README to do that in your plugin.This will solve your problem.
In my comment above, you no need to call this API every seconds. The websocket's onmessage callback will give you which API is called and its data.
ws.onmessage = async message => { const data = JSON.parse(message.data) console.log(data) const api = /* extract the data to get API */ if (api === '/lol-gameflow/v1/gameflow-phase') { // todo } }
Oh, there's been a misunderstanding.
When I said I sent a GET request and that it worked, I meant that I tried :
async function acceptMatchFound() {
await fetch('/lol-matchmaking/v1/ready-check/accept', {
method: 'POST'
})
}
The issue I had with the subscribe() function is that it wouldn't send back anything else than the initial response :
After this when I connected to a champ-select, or when someone sent a message in champ-select, it wouldn't tell me(I put a console.log() inside it printing "yay", as you see it gets triggered once but then it doesn't anymroe)
Here is the code I pasted in the console to clear any misunderstanding :
function subscribe() {
const uri = document.querySelector('link[rel="riot:plugins:websocket"]').href
const ws = new WebSocket(uri, 'wamp')
ws.onopen = () => ws.send(JSON.stringify([5, 'JsonApiEvent']))
ws.onmessage = async message => {
const data = JSON.parse(message.data)
console.log(data)
console.log("yay")
}
}
from penguloader.
I'm sorry, the event name JsonApiEvent
was wrong.
The correct name is OnJsonApiEvent
.
-ws.onopen = () => ws.send(JSON.stringify([5, 'JsonApiEvent']))
+ws.onopen = () => ws.send(JSON.stringify([5, 'OnJsonApiEvent']))
from penguloader.
Related Issues (20)
- Grouping plugins by author HOT 1
- Shared TS types & enhancement HOT 1
- Experiment: TypeScript and JSX Support 🗿
- Plugin Browser HOT 3
- erro microsoft HOT 2
- Stream Bugged HOT 1
- How will the new League of Legends anti cheat Vanguard react to Pengu's injection into the LCU? HOT 5
- Discord Invites HOT 1
- Discord Invites are closed HOT 1
- 能否增加一个拦截直播弹窗? HOT 1
- Options to disable Pengu Loader loading screen and toast message HOT 5
- custom scheme HOT 8
- Cannot click active status on HOT 1
- Feature: a fallback injection method using symlink HOT 1
- Mutliple LeagueClient support
- Bug: Application Error in rundll32.exe
- Simple Optimization HOT 3
- Bootstrapper failed with error 0x5
- DevTools display on 2k screen HOT 3
- rcp.whenReady should support for late init HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from penguloader.