2020-04-04 12:42:02 +02:00
|
|
|
export class Message {
|
|
|
|
userId: string;
|
|
|
|
roomId: string;
|
|
|
|
|
|
|
|
constructor(message: string) {
|
|
|
|
let data = JSON.parse(message);
|
2020-04-04 17:22:02 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
toJson() {
|
|
|
|
return {
|
|
|
|
userId: this.userId,
|
|
|
|
roomId: this.roomId,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|