I'm designing a game that makes use of websockets for realtime communication of game moves and chat between participants.
I also need clients to make metadata operations, such as:
- create a new game table
- get the list of participants in the current game
- invite other users
- etc.
My question is, should these operation be performed in the already existing websocket connection, or should I create REST API endpoints for them?
The advantage for using websockets is that it's already open, so it will be faster, and I have the user authentication already in place.
The advantage of using API is that all of these operations are very natural to request/response communication. I mean if I will need to implement it in websockets, that client will issue a request, and the response will come sometime in the future (maybe), and I will have to scan the stream of messages in the socket and assign each response to the corresponding request manually.
Any other points I should take into considerations, and what is your take on this?