partey_workadventure/back/src/Model/Admin.ts
2021-06-24 10:09:10 +02:00

35 lines
1.1 KiB
TypeScript

import {
ServerToAdminClientMessage,
UserJoinedRoomMessage,
UserLeftRoomMessage,
} from "../Messages/generated/messages_pb";
import { AdminSocket } from "../RoomManager";
export class Admin {
public constructor(private readonly socket: AdminSocket) {}
public sendUserJoin(uuid: string, name: string, ip: string): void {
const serverToAdminClientMessage = new ServerToAdminClientMessage();
const userJoinedRoomMessage = new UserJoinedRoomMessage();
userJoinedRoomMessage.setUuid(uuid);
userJoinedRoomMessage.setName(name);
userJoinedRoomMessage.setIpaddress(ip);
serverToAdminClientMessage.setUserjoinedroom(userJoinedRoomMessage);
this.socket.write(serverToAdminClientMessage);
}
public sendUserLeft(uuid: string /*, name: string, ip: string*/): void {
const serverToAdminClientMessage = new ServerToAdminClientMessage();
const userLeftRoomMessage = new UserLeftRoomMessage();
userLeftRoomMessage.setUuid(uuid);
serverToAdminClientMessage.setUserleftroom(userLeftRoomMessage);
this.socket.write(serverToAdminClientMessage);
}
}