workadventure/back/src/Model/Websocket/Message.ts

26 lines
580 B
TypeScript
Raw Normal View History

export class Message {
userId: string;
roomId: string;
name: string;
character: string;
2020-04-07 10:08:04 +02:00
constructor(data: any) {
2020-04-27 00:44:25 +02:00
if (!data.userId || !data.roomId) {
2020-04-06 15:48:19 +02:00
throw Error("userId or roomId cannot be null");
}
this.userId = data.userId;
this.roomId = data.roomId;
this.name = data.name;
this.character = data.character;
}
toJson() {
return {
userId: this.userId,
roomId: this.roomId,
name: this.name,
character: this.character
}
}
}