partey_workadventure/back/src/Model/Admin.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

import {
ServerToAdminClientMessage,
UserJoinedRoomMessage, UserLeftRoomMessage
} from "../Messages/generated/messages_pb";
import {AdminSocket} from "../RoomManager";
export class Admin {
public constructor(
private readonly socket: AdminSocket
) {
}
2021-01-15 03:19:58 +01:00
public sendUserJoin(uuid: string, name: string, ip: string): void {
2021-01-18 15:31:19 +01:00
const serverToAdminClientMessage = new ServerToAdminClientMessage();
2021-01-18 15:07:40 +01:00
2021-01-18 15:31:19 +01:00
const userJoinedRoomMessage = new UserJoinedRoomMessage();
2021-01-18 15:07:40 +01:00
userJoinedRoomMessage.setUuid(uuid);
userJoinedRoomMessage.setName(name);
userJoinedRoomMessage.setIpaddress(ip);
serverToAdminClientMessage.setUserjoinedroom(userJoinedRoomMessage);
this.socket.write(serverToAdminClientMessage);
}
2021-01-18 15:07:40 +01:00
public sendUserLeft(uuid: string/*, name: string, ip: string*/): void {
2021-01-18 15:31:19 +01:00
const serverToAdminClientMessage = new ServerToAdminClientMessage();
2021-01-18 15:07:40 +01:00
2021-01-18 15:31:19 +01:00
const userLeftRoomMessage = new UserLeftRoomMessage();
2021-01-18 15:07:40 +01:00
userLeftRoomMessage.setUuid(uuid);
serverToAdminClientMessage.setUserleftroom(userLeftRoomMessage);
this.socket.write(serverToAdminClientMessage);
}
}