Add io socket message to share user position.
- Add message 'user-position' to share position in a room. - Change JoinRoomMessage to MessageUserPosition to have all data to share position and user information - Fix error alias to build
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
export class JoinRoomMessage {
|
||||
userId: string;
|
||||
roomId: string;
|
||||
positionXUser: string;
|
||||
positionYUser: string;
|
||||
|
||||
constructor(message: string) {
|
||||
let data = JSON.parse(message);
|
||||
this.userId = data.userId;
|
||||
this.roomId = data.roomId;
|
||||
this.positionXUser = data.positionXUser;
|
||||
this.positionYUser = data.positionYUser;
|
||||
}
|
||||
|
||||
toString(){
|
||||
return JSON.stringify({
|
||||
userId: this.userId,
|
||||
roomId: this.roomId,
|
||||
positionXUser: this.positionXUser,
|
||||
positionYUser: this.positionYUser
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
export class Message {
|
||||
userId: string;
|
||||
roomId: string;
|
||||
|
||||
constructor(message: string) {
|
||||
let data = JSON.parse(message);
|
||||
this.userId = data.userId;
|
||||
this.roomId = data.roomId;
|
||||
}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
userId: this.userId,
|
||||
roomId: this.roomId,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import {Message} from "./Message";
|
||||
|
||||
export class MessageUserPosition extends Message{
|
||||
positionXUser: string;
|
||||
positionYUser: string;
|
||||
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
let data = JSON.parse(message);
|
||||
this.positionXUser = data.positionXUser;
|
||||
this.positionYUser = data.positionYUser;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return JSON.stringify(
|
||||
Object.assign(
|
||||
super.toJson(),
|
||||
{
|
||||
positionXUser: this.positionXUser,
|
||||
positionYUser: this.positionYUser
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user