From 1100edecb7b795203e15f7c90fa4de9c8f037e69 Mon Sep 17 00:00:00 2001 From: gparant Date: Sat, 4 Apr 2020 22:43:07 +0200 Subject: [PATCH] Add readme of features and communication in back --- README.md | 3 + back/README.md | 61 +++++++++++++++++++ .../Model/Websocket/MessageUserPosition.ts | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 back/README.md diff --git a/README.md b/README.md index 61ee39f0..9c9a110a 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,6 @@ Vagrant destroy * `Vagrant ssh`: connect on your VM Vagrant. * `Vagrant halt`: stop your VM Vagrant. * `Vagrant destroy`: delete your VM Vagrant. + +## Features developed +You have more details of features developed in back [README.md](./back/README.md). \ No newline at end of file diff --git a/back/README.md b/back/README.md new file mode 100644 index 00000000..12a9fcab --- /dev/null +++ b/back/README.md @@ -0,0 +1,61 @@ +# Back Features + +## Login +To start your game, you must authenticate on the server back. +When you are authenticated, the back server return token and rooms started. +``` +POST => /login +Params : + email: email of user. +``` + +## Join a room +When a user is connected, the user can join a room. +So you must send emit `join-room` with information user: +``` +Socket.io => 'join-room' + + userId: user id of gamer + roomId: room id when user enter in game + position: { + x: position x on map + y: position y on map + } +``` +All data users are stocked on socket client. + +## Send position user +When user move on the map, you can share new position on back with event `user-position`. +The information sent: +``` +Socket.io => 'user-position' + + userId: user id of gamer + roomId: room id when user enter in game + position: { + x: position x on map + y: position y on map + } +``` +All data users are updated on socket client. + +## Receive positions of all users +The application sends position of all users in each room in every few 10 milliseconds. +The data will pushed on event `user-position`: +``` +Socket.io => 'user-position' + + [ + { + userId: user id of gamer + roomId: room id when user enter in game + position: { + x: position x on map + y: position y on map + } + }, + ... + ] +``` + +[<<< back](../README.md) \ No newline at end of file diff --git a/back/src/Model/Websocket/MessageUserPosition.ts b/back/src/Model/Websocket/MessageUserPosition.ts index 731d60ff..b5aeaee5 100644 --- a/back/src/Model/Websocket/MessageUserPosition.ts +++ b/back/src/Model/Websocket/MessageUserPosition.ts @@ -22,7 +22,7 @@ export class Point implements PointInterface{ } export class MessageUserPosition extends Message{ - position: PointInterface + position: PointInterface; constructor(message: string) { super(message);