workadventure/back/src/Model/Websocket/Message.ts
2020-04-06 15:48:19 +02:00

20 lines
443 B
TypeScript

export class Message {
userId: string;
roomId: string;
constructor(message: string) {
let data = JSON.parse(message);
if(!data.userId || !data.roomId){
throw Error("userId or roomId cannot be null");
}
this.userId = data.userId;
this.roomId = data.roomId;
}
toJson() {
return {
userId: this.userId,
roomId: this.roomId,
}
}
}