Implement Distance Merge Request

This commit is contained in:
gparant 2020-04-27 00:44:25 +02:00
parent c907048c12
commit 881bb04eb0
3 changed files with 27 additions and 8 deletions

View file

@ -3,7 +3,7 @@ export class Message {
roomId: string;
constructor(data: any) {
if(!data.userId || !data.roomId){
if (!data.userId || !data.roomId) {
throw Error("userId or roomId cannot be null");
}
this.userId = data.userId;
@ -13,7 +13,7 @@ export class Message {
toJson() {
return {
userId: this.userId,
roomId: this.roomId,
roomId: this.roomId
}
}
}

View file

@ -27,10 +27,9 @@ export class Point implements PointInterface{
export class MessageUserPosition extends Message{
position: PointInterface;
constructor(message: string) {
constructor(message: any) {
super(message);
let data = JSON.parse(message);
this.position = new Point(data.position.x, data.position.y, data.position.direction);
this.position = new Point(message.position.x, message.position.y, message.position.direction);
}
toString() {