-
Notifications
You must be signed in to change notification settings - Fork 0
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
Socket.io API endpoint for players of a game to start real-time communication #37
Comments
設計方針是只與GaaS大平台串接還是會有考慮其他遊戲登錄平台?
不是很懂,看前面一條我以為是在討論REST endpoint? 在我們遊戲這個case,
是在講Kafka?我還沒開始看,暫時不了解設計上需要什麼 如果是在講socket.io的 加上之前討論我說
為了舉例方便,我用JSON示範 # 已從Kafka接收到新的難度等級
new_difficulty_level = STANDARD
# 發布遊戲狀態更新到前端
sio.emit(
'game',
{'event': CHANGE_DIFFICULTY_STATE,
'difficulty': new_difficulty_level},
to=game_id
) |
Hi, Ted, 我先回答部分問題
只考慮 GaaS 大平台
是的, 目前的 GaaS 大平台 無法增加更多玩家到 已存在的遊戲房間
但ok , 這也不是關鍵功能,可以先不考慮
這不是
所以我最初的comment 是問你們對 namespaces, topics 的命名規則有何偏好
OK
Where to place the game ID ? should game ID be part of topic or namespace ? like |
Hi, Ted , continue to reply rest of the questions
please ignore the message , it is unrelated to Kafka ,
I prefer the 2nd design option, but I am not sure whether I can set up the namespace such like |
想問一下 我在想把卡有關的的endpoints |
抱歉,我只是舉個例子, 目前我還沒考慮實作細節 Finally I got some time to work on the socket.io server, I will first start implementation which publish / subscribes message with the following topics -- 我目前正在做的 socket.io topics
|
To everyone following / interested with this issue, here is the experiment result, [1] [2]
After coding with [3]
[4] |
Signed-off-by: T.H. <metalalive2008@gmail.com>
Signed-off-by: Han Woo <metalalive2008@gmail.com>
To @wingtkw : I am considering to add another API doc at To anyone interested with the work, |
TODOthe list is what I will do : Portion 1
create PR, merge to main branch --- (done in 11th Dec 2023) Portion 2
create PR, merge to main branch --- (done in 26th Jan 2024) Portion 3
create PR, merge to main branch --- (done in 1st Feb 2024) Portion 4
create PR, merge to main branch --- (done in 7th Feb 2024) Tasks NOT included in this TODO list
|
我注意到實驗分支 experiment/backend/socketio 實作中 一些相關討論: 補充說明:
socket.io 文件通常用 AsyncAPI 撰寫, 但我不確定同樣放在 |
Hi , Ted
The naming convention of
thanks, good to know about |
- remove unnecessary forward slash character in event name - check fields `msg` and `nickname` in the event data `chat` - logger to record server errors Signed-off-by: T.H. <metalalive2008@gmail.com>
- validate event arguments with pydantic base model - rename the field `room` to game ID in `init` , `deinit` events - add the field `nickname` to the event data `init` and `deinit` - move constants , configurable parameters in appropriate modules Signed-off-by: T.H. <metalalive2008@gmail.com>
Signed-off-by: T.H. <metalalive2008@gmail.com>
- Socket.io server for real-time communication in the game - currently only some events `init` (join room), `deinit` (leave room), `chat` are implemented
Let us focus on the 2nd portion of the TODO list in this GitHub Issue , discussion related to the design / implementation are appreciated.
[update 15th Dec 2023] [update 11th Jan 2024] [update 23th Jan 2024]
|
Let me review it on 15 |
… game - socketio server collects the events, to know all the ongoing games - http server maintains a shared socketio client sending all relavant events - rename `AbstractRepository` to `AbstractGameRepository` - TODO, implement room repository for real-time communication Signed-off-by: T.H. <metalalive2008@gmail.com>
- implement (currently in-memory) room repository , so the socketio server knows all the ongoing games - check from the room repository when player attempts to initialize (or de-initialize) real-time communication (RTC) through the socketio event `INIT` (or `DEINIT`) - add new member to `GameFuncCodes`, for RTC endpoints (e.g. currently `socketio`) Signed-off-by: T.H. <metalalive2008@gmail.com>
…ackend/socketio/create-game Hi @wingtkw , As I described above I will merge the PR first , you are still welcome to leave comment at here, or create another issue / discussion thread for any question about learning my code at here
I am working on the 3rd portion of the TODO list in this GitHub Issue , discussion related to the design / implementation are appreciated. |
- http server emits corresponding event on completing the operations to socket.io server - socket.io server simply forwards the game-state messages to corresponding players of a given game Signed-off-by: T.H. <metalalive2008@gmail.com>
…acter-selection-before-start Emit events on difficulty and character update
I will work on the 4th (final) portion of the TODO list in this GitHub Issue. I'll try @wingtkw , @KalpasWang , @liamlin1102 |
- integrate with FlatBuffers - binary payload generaated on switch-character event Signed-off-by: T.H. <metalalive2008@gmail.com>
- integrate with FlatBuffers - binary payload generated on difficulty-config event Signed-off-by: T.H. <metalalive2008@gmail.com>
…ckend/socketio/flatbuffer-payload - apply FlatBuffers payload to socket.io server on game config events - currently this affects the 2 events, such as switch character, set difficulty level - Other (future) events reflecting change of the game state can encode / decode payload in the same way for enhancing performance.
Currently close this Issue, c.c. @wingtkw , @KalpasWang |
@metalalive |
API endpoint to
socket.io
serverlocalhost:8082
, path/
,GET method, no request bodyInteraction with
socket.io
serverClient (Player)
Possible events namespace to emit (or topics to publish)
/game/{game-id}/join
<-- Not sure whether this is good design optionplayer-id = abc999xyz
/game/{game-id}/chat
player-id = abg007xyz
,chat-message = Hello World
Possible events namespace to receive (topics to subscribe)
/game/{game-id}/config/difficulty
level = standard
,/game/{game-id}/config/investigators
player-id = SamuraiBuck
,investigator = magician
There should be many more topics to subscribe for each player
HTTP RESTful server
Possible events namespace to emit (or topics to publish)
/game/{game-id}/config/difficulty
/game/{game-id}/config/investigators
Possible events namespace to receive (topics to subscribe)
Question
/game/{game-id}/join
, <-- is this good design option ?/game/{game-id}/join
? to let the HTTP RESTful server know one more person would like to join , then re-useGame.add_player()
in backend code.TODO
python-socketio
and Kafka)Reference
See previous discussion #29
@wingtkw @teds-lin , plz take a look at this,
feedback or suggestion are welcome , thanks.
The text was updated successfully, but these errors were encountered: