ROSE
ROSE copied to clipboard
Use websocket for client communication
Currently we have listen to 2 ports:
- TCP/8888 - using line based protocol, used by rose-client
- TCP/8880 - used for web side, xmlrpc, and websocket
Trying to deploy on Heroku (see #187), it seems that we don't have a way to serve a custom port in this platform. I'm not sure if this is also an issue on OpenShift.
We discussed offline the option of replacing the custom port with websocket, enabling deployment on Heruko and other platforms that are optimized for web development.
New design
Player connection protocol
- player: connect to server using websocket
- server: accept connection, wait for message
- player: send "join" message
- server: register player, send "update" message to all clients
Watcher connection protocol
- watcher: connect to server using websocket
- server: accept connection, wait for message
- watcher: send "watch" message
- server: register watcher, send "update" message to all clients
Game protocol
- server: send "update" message with "started: true" to all clients
- player: send "drive" message
- watcher: update the UI
Game completion
- server: send "update" message with "started: false"
- player: ignore
- watcher: update the UI
Changes needed
- rose/client/main.py:
- implement Client using WebSocketClientProtocol see: https://github.com/crossbario/autobahn-python/blob/master/examples/twisted/websocket/echo/client.py
- rose/server/net.py:
- handle messages from remote clients
- detect if client is a watcher or a player
- add player or watcher to the Hub
- remove PlayerProtocol, PlayerFactory
- rose/server/main.py:
- Remove the code listening to the client port (8888)
@cben, @yaacov, @rollandf, can you review this?
I think we need to convert this proposal to documentation. We should have docs/architecture.md document explaining how the game works.