예제 #1
0
        public override async void OnMessage(WebSocket socket, WebSocketHandler handler, JsonData message)
        {
            base.OnMessage(socket, handler, message);

            var data    = message["Data"];
            var lobbyid = data["lobbyid"].ToString();

            RoomInfo room  = null;
            var      lobby = LobbyMgr.GetLobby(lobbyid);

            if (lobby != null)
            {
                room = lobby.OnMate(socket);
            }
            var json = new JsonData();

            if (room == null)
            {
                json["result"] = (int)ResultCode.Failed;
            }
            else
            {
                json["result"] = (int)ResultCode.Success;
                json["roomid"] = room.RoomId;
            }
            var retMssage = new WebSocketManager.Message()
            {
                CommandId   = Protocal.ReqMate,
                MessageType = MessageType.Json,
                Data        = JsonMapper.ToJson(json)
            };
            await handler.SendMessageAsync(socket, retMssage);

            logger.Info("OnMessage: " + json["result"]);
        }
        public override async void OnMessage(WebSocket socket, WebSocketHandler handler, JsonData message)
        {
            base.OnMessage(socket, handler, message);
            var data    = message["Data"];
            var lobbyid = data["lobbyid"].ToString();

            var lobby = LobbyMgr.GetLobby(lobbyid);

            if (lobby != null)
            {
                lobby.OnLeave(socket);
            }
        }