Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lobby room send message with empty rooms array when join without option #53

Open
bedryck opened this issue Feb 8, 2024 · 0 comments
Open

Comments

@bedryck
Copy link

bedryck commented Feb 8, 2024

``This is what happens in my opinion, when I am trying to connect without options, the library by default creates such payload for request:
image
image

Also, I add curl

curl 'http://localhost:3000/matchmake/joinOrCreate/lobby?' \
  -H 'Accept: application/json' \
  -H 'Accept-Language: en-US,en;q=0.9,ru-UA;q=0.8,ru;q=0.7,uk;q=0.6' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNrbmFtZSI6InRlc3QyIiwiaWQiOiI2NWEyNGVlOTc2ZDBhNDZjMjk4OGExYmYiLCJpYXQiOjE3MDc0MjkyNDYsImV4cCI6MTcwNzUxNTY0Nn0.bMsByH_8yrWgFIdVk9FziDxUy4LjT313UtrHHOU4jg8' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Origin: http://localhost:58320' \
  -H 'Pragma: no-cache' \
  -H 'Referer: http://localhost:58320/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw '[]' \
  --compressed

Then in https://github.com/colyseus/colyseus/blob/master/packages/core/src/rooms/LobbyRoom.ts when calls
client.send('rooms', this.filterItemsForClient(this.clientOptions[client.sessionId])); we call this method with options with value [] - array
client.send('rooms', this.filterItemsForClient([])); and it can not work with such a data type
And then in my socket connection I get "room" massage with empty rooms:
image

This can be easily fixed if you send any option, to change the default value from an empty array to an object. Example
image

curl "http://localhost:3000/matchmake/joinOrCreate/lobby?" ^
  -H "Accept: application/json" ^
  -H "Accept-Language: en-US,en;q=0.9,ru-UA;q=0.8,ru;q=0.7,uk;q=0.6" ^
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNrbmFtZSI6InRlc3QyIiwiaWQiOiI2NWEyNGVlOTc2ZDBhNDZjMjk4OGExYmYiLCJpYXQiOjE3MDc0MjkyNDYsImV4cCI6MTcwNzUxNTY0Nn0.bMsByH_8yrWgFIdVk9FziDxUy4LjT313UtrHHOU4jg8" ^
  -H "Cache-Control: no-cache" ^
  -H "Connection: keep-alive" ^
  -H "Content-Type: application/json" ^
  -H "Origin: http://localhost:58320" ^
  -H "Pragma: no-cache" ^
  -H "Referer: http://localhost:58320/" ^
  -H "Sec-Fetch-Dest: empty" ^
  -H "Sec-Fetch-Mode: cors" ^
  -H "Sec-Fetch-Site: same-site" ^
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" ^
  -H "sec-ch-ua: ^\^"Not A(Brand^\^";v=^\^"99^\^", ^\^"Google Chrome^\^";v=^\^"121^\^", ^\^"Chromium^\^";v=^\^"121^\^"" ^
  -H "sec-ch-ua-mobile: ?0" ^
  -H "sec-ch-ua-platform: ^\^"Windows^\^"" ^
  --data-raw "^{^\^"test^\^":^\^"test^\^"^}" ^
  --compressed

and then I get correct rooms data

image

@bedryck bedryck changed the title Lobby returns empty rooms array when join without option Lobby room send message with empty rooms array when join without option Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant