2020-04-04 12:42:02 +02:00
|
|
|
export class Message {
|
|
|
|
userId: string;
|
|
|
|
roomId: string;
|
2020-05-03 22:24:14 +02:00
|
|
|
name: string;
|
2020-05-08 15:18:22 +02:00
|
|
|
character: string;
|
2020-04-04 12:42:02 +02:00
|
|
|
|
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");
|
2020-04-04 17:22:02 +02:00
|
|
|
}
|
2020-04-04 12:42:02 +02:00
|
|
|
this.userId = data.userId;
|
|
|
|
this.roomId = data.roomId;
|
2020-05-03 22:24:14 +02:00
|
|
|
this.name = data.name;
|
2020-05-08 15:18:22 +02:00
|
|
|
this.character = data.character;
|
2020-04-04 12:42:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
toJson() {
|
|
|
|
return {
|
|
|
|
userId: this.userId,
|
2020-05-03 22:24:14 +02:00
|
|
|
roomId: this.roomId,
|
2020-05-06 01:50:01 +02:00
|
|
|
name: this.name,
|
2020-05-08 15:18:22 +02:00
|
|
|
character: this.character
|
2020-04-04 12:42:02 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-08 15:18:22 +02:00
|
|
|
}
|