Open rjawesome opened 11 months ago
server {
server_name game.rohanj.dev;
location / {
proxy_pass http://localhost:10550;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Node.js Server
node index.js
Creating a socket.io client
Obtaining and using the ID for this client
Using the ID to determine the appropriate ID for the player object
Exporting information about Objects to Server
this.shouldBeSynced = false
, set totrue
in thePlayer
classBeing able to add a character to the level in realtime
addCharacter
method has been added: https://github.com/nighthawkcoders/teacher_portfolio/blob/d6705898dd2a2d8786df2f08e4e1e21d0d54cc01/assets/js/multiplayer/GameLevel.js#L89Changing a gameObject based on JSON info
jsonify
Ingesting player Updates from the Server
handleSocketMessage
looks for a gameObject with the ID specified in the message and uses theupdateInfo
method, if none exists it uses the level's addCharacter method: https://github.com/nighthawkcoders/teacher_portfolio/blob/d6705898dd2a2d8786df2f08e4e1e21d0d54cc01/assets/js/multiplayer/GameControl.js#L69Deleting players when someone leaves
handleSocketMessage
there is ahandleSocketDisconnect
which is assigned in the same part of code to the disconnection event: https://github.com/nighthawkcoders/teacher_portfolio/blob/d6705898dd2a2d8786df2f08e4e1e21d0d54cc01/assets/js/multiplayer/GameControl.js#L34