iczero / lol-client-api

Various utilities and stuff for use with the League of Legends Client API
MIT License
8 stars 0 forks source link

Q: About sending args on wamprequest #7

Closed muratulashozturk closed 3 years ago

muratulashozturk commented 3 years ago

Hi, I was wondering about how to send JSON with wamprequest.

For example setting name.

HTTP:

POST /lol-summoner/v1/summoners , body: {"name":"summonerName"}

So I want to send this request with wamprequest through WebSocket. Should I need to do

await api.wampRequest('POST /lol-summoner/v1/summoners, "{\"name\":\"summonerName\"}");

? Also will the output

[2,"randomUUIDV1","POST /lol-summoner/v1/summoners","{\"name\":\"summonerName\"}"]

like this?

Thanks.

iczero commented 3 years ago

You should be able to pass objects directly. Code for wampRequest is here: https://github.com/iczero/lol-client-api/blob/master/src/LeagueClientAPI.js#L203

In your example, try

await api.wampRequest('POST /lol-summoner/v1/summoners', { name: 'summonerName' });

It should send

[2, "requestId", "POST /lol-summoner/v1/summoners", { "name": "summonerName" }]
muratulashozturk commented 3 years ago

Alright, buddy. I will give it a try today and let you know If It's working or not.

iczero commented 3 years ago

One more thing, please keep in mind this code hasn't been updated for 2 years (a very long time!) as I am no longer currently playing League. Parts of it are likely to not work anymore.

muratulashozturk commented 3 years ago

Yeah, no problem with that. I am not playing LoL too nor know it too much haha. I am currently writing a full LCU API wrapper in C#. I figured everything but I was just checking If we can send the HTTP requests with WebSocket. I will give it a try. If It's not working (probably updated), I'm going to look at packets with Fiddler to see what changed. Thanks for the information btw.

muratulashozturk commented 3 years ago

Test successful! I tried creating a lobby with WebSocket and it worked.

muratulashozturk commented 3 years ago

Hi, it's me again. It's all working but after connecting websocket, When I close the league client, I cannot relaunch again while the terminal is running. If I close the terminal then it's starting to launch. Do you know why this is happening? I tried everything. Closed websocket connection etc but none of them working.

iczero commented 3 years ago

I'm not sure. I don't recall that ever being an issue. Closing the LeagueClientUx window should quit LeagueClient and thus disconnect the websocket client. Upon restart of LeagueClient, the websocket client should simply rediscover the lockfile and reconnect.

muratulashozturk commented 3 years ago

Well yeah It is normally what needed to happen but it's the client is not starting unless i close the terminal. Really weird