partey_workadventure/back/src/Model/Admin.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

import {
ServerToAdminClientMessage,
2021-06-24 10:09:10 +02:00
UserJoinedRoomMessage,
UserLeftRoomMessage,
} from "../Messages/generated/messages_pb";
2021-06-24 10:09:10 +02:00
import { AdminSocket } from "../RoomManager";
export class Admin {
2021-06-24 10:09:10 +02:00
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-06-24 10:09:10 +02: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);
}
}