Permit to dissociate data by room
- Update share room id. - Join room when a scene is loaded. - Add a room in constant variable.
This commit is contained in:
parent
27c6034661
commit
5f11b065e1
7 changed files with 46 additions and 27 deletions
|
@ -147,7 +147,7 @@ export interface ConnexionInterface {
|
|||
|
||||
joinARoom(roomId: string, character: string): void;
|
||||
|
||||
sharePosition(x: number, y: number, direction: string, character: string): void;
|
||||
sharePosition(x: number, y: number, direction: string, roomId: string, character: string): void;
|
||||
|
||||
positionOfAllUser(): void;
|
||||
|
||||
|
@ -182,7 +182,7 @@ export class Connexion implements ConnexionInterface {
|
|||
return Axios.post(`${API_URL}/login`, {email: this.email})
|
||||
.then((res) => {
|
||||
this.token = res.data.token;
|
||||
this.startedRoom = res.data.roomId;
|
||||
this.startedRoom = res.data.startedRoom.key;
|
||||
this.userId = res.data.userId;
|
||||
|
||||
this.socket = SocketIo(`${API_URL}`, {
|
||||
|
@ -195,7 +195,7 @@ export class Connexion implements ConnexionInterface {
|
|||
this.joinARoom(this.startedRoom, characterSelected);
|
||||
|
||||
//share your first position
|
||||
this.sharePosition(0, 0, characterSelected);
|
||||
this.sharePosition(0, 0, characterSelected, this.startedRoom);
|
||||
|
||||
this.positionOfAllUser();
|
||||
|
||||
|
@ -229,7 +229,7 @@ export class Connexion implements ConnexionInterface {
|
|||
joinARoom(roomId: string, character: string): void {
|
||||
let messageUserPosition = new MessageUserPosition(
|
||||
this.userId,
|
||||
this.startedRoom,
|
||||
roomId,
|
||||
new Point(0, 0),
|
||||
this.email,
|
||||
character
|
||||
|
@ -242,15 +242,16 @@ export class Connexion implements ConnexionInterface {
|
|||
* @param x
|
||||
* @param y
|
||||
* @param character
|
||||
* @param roomId
|
||||
* @param direction
|
||||
*/
|
||||
sharePosition(x : number, y : number, character : string, direction : string = "none") : void{
|
||||
sharePosition(x : number, y : number, character : string, roomId : string, direction : string = "none") : void{
|
||||
if(!this.socket){
|
||||
return;
|
||||
}
|
||||
let messageUserPosition = new MessageUserPosition(
|
||||
this.userId,
|
||||
ROOM[0],
|
||||
roomId,
|
||||
new Point(x, y, direction),
|
||||
this.email,
|
||||
character
|
||||
|
@ -276,10 +277,9 @@ export class Connexion implements ConnexionInterface {
|
|||
positionOfAllUser(): void {
|
||||
this.socket.on(EventMessage.USER_POSITION, (message: string) => {
|
||||
let dataList = JSON.parse(message);
|
||||
dataList.forEach((UserPositions: any) => {
|
||||
let listMessageUserPosition = new ListMessageUserPosition(UserPositions[0], UserPositions[1]);
|
||||
this.GameManager.shareUserPosition(listMessageUserPosition);
|
||||
});
|
||||
let UserPositions : Array<any> = Object.values(dataList);
|
||||
let listMessageUserPosition = new ListMessageUserPosition(UserPositions[0], UserPositions[1]);
|
||||
this.GameManager.shareUserPosition(listMessageUserPosition);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue