diff --git a/back/src/Model/Admin.ts b/back/src/Model/Admin.ts index 53757e96..9d9c85ce 100644 --- a/back/src/Model/Admin.ts +++ b/back/src/Model/Admin.ts @@ -9,7 +9,7 @@ import { PusherToBackMessage, ServerToAdminClientMessage, ServerToClientMessage, - SubMessage + SubMessage, UserJoinedRoomMessage, UserLeftRoomMessage } from "../Messages/generated/messages_pb"; import {CharacterLayer} from "_Model/Websocket/CharacterLayer"; import {AdminSocket} from "../RoomManager"; @@ -23,13 +23,25 @@ export class Admin { public sendUserJoin(uuid: string, name: string, ip: string): void { let serverToAdminClientMessage = new ServerToAdminClientMessage(); - serverToAdminClientMessage = serverToAdminClientMessage.setUseruuidnamejoinedroom(uuid+';'+name+';'+ip) + + let 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 { + public sendUserLeft(uuid: string/*, name: string, ip: string*/): void { let serverToAdminClientMessage = new ServerToAdminClientMessage(); - serverToAdminClientMessage = serverToAdminClientMessage.setUseruuidnameleftroom(uuid+';'+name+';'+ip); + + let userLeftRoomMessage = new UserLeftRoomMessage(); + userLeftRoomMessage.setUuid(uuid); + + serverToAdminClientMessage.setUserleftroom(userLeftRoomMessage); + this.socket.write(serverToAdminClientMessage); } } diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 8a57ee99..41c215ad 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -145,7 +145,7 @@ export class GameRoom { // Notify admins for (const admin of this.admins) { - admin.sendUserLeft(user.uuid, user.name, user.IPAddress); + admin.sendUserLeft(user.uuid/*, user.name, user.IPAddress*/); } } diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index b6846f3d..b6a82850 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -203,8 +203,8 @@ const roomManager: IRoomManagerServer = { callback(null, new EmptyMessage()); }, ban(call: ServerUnaryCall, callback: sendUnaryData): void { - - socketManager.banUser(call.request.getRoomid(), call.request.getRecipientuuid()); + // FIXME Work in progress + socketManager.banUser(call.request.getRoomid(), call.request.getRecipientuuid(), 'foo bar TODO change this'); callback(null, new EmptyMessage()); }, diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 64f18f13..39f575be 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -316,10 +316,20 @@ message ServerToAdminClientMessage { repeated SubToAdminPusherMessage payload = 2; }*/ +message UserJoinedRoomMessage { + string uuid = 1; + string ipAddress = 2; + string name = 3; +} + +message UserLeftRoomMessage { + string uuid = 1; +} + message ServerToAdminClientMessage { oneof message { - string userUuidNameJoinedRoom = 1; - string userUuidNameLeftRoom = 2; + UserJoinedRoomMessage userJoinedRoom = 1; + UserLeftRoomMessage userLeftRoom = 2; } } diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index f5915ddb..eedb1e7a 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -23,7 +23,7 @@ import { AdminPusherToBackMessage, ServerToAdminClientMessage, SendUserMessage, - BanUserMessage + BanUserMessage, UserJoinedRoomMessage, UserLeftRoomMessage } from "../Messages/generated/messages_pb"; import {PointInterface} from "../Model/Websocket/PointInterface"; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; @@ -77,15 +77,28 @@ export class SocketManager implements ZoneEventListener { client.adminConnection = adminRoomStream; adminRoomStream.on('data', (message: ServerToAdminClientMessage) => { - if (message.hasUseruuidnamejoinedroom()) { - const userUuidName = message.getUseruuidnamejoinedroom(); + if (message.hasUserjoinedroom()) { + const userJoinedRoomMessage = message.getUserjoinedroom() as UserJoinedRoomMessage; if (!client.disconnecting) { - client.send('MemberJoin:'+userUuidName+';'+roomId); + client.send(JSON.stringify({ + type: 'MemberJoin', + data: { + uuid: userJoinedRoomMessage.getUuid(), + name: userJoinedRoomMessage.getName(), + ipAddress: userJoinedRoomMessage.getIpaddress(), + roomId: roomId, + } + })); } - } else if (message.hasUseruuidnameleftroom()) { - const userUuidName = message.getUseruuidnameleftroom(); + } else if (message.hasUserleftroom()) { + const userLeftRoomMessage = message.getUserleftroom() as UserLeftRoomMessage; if (!client.disconnecting) { - client.send('MemberLeave:'+userUuidName+';'+roomId); + client.send(JSON.stringify({ + type: 'MemberLeave', + data: { + uuid: userLeftRoomMessage.getUuid() + } + })); } } else { throw new Error('Unexpected admin message');