Beispiel #1
0
 void Start()
 {
     createRoom = GameObject.Find("Player").GetComponent <CreateRoom>();
 }
Beispiel #2
0
        private void Server_ObjectReceived(object sender, AdvancedNetworkLib.ObjectReceivedEventArgs e)
        {
            AdvancedNetworkLib.Client client   = (sender as AdvancedNetworkLib.Client);
            ClientUserData            userData = client.UserData as ClientUserData;
            RoomInfo roomInfo = this.rooms.Find(c => c.Name == userData?.RoomName);

            var obj = e.Object;

            if (obj is ServerPassword)
            {
                ServerPassword serverPassword = obj as ServerPassword;
                this.checkServerPassword(client, serverPassword);
            }
            else if (obj is ChangeState)
            {
                var         oldState    = userData.State;
                ChangeState changeState = obj as ChangeState;
                userData.State = changeState.State;

                if (userData.State == State.RoomChoice)
                {
                    userData.PlayerName = string.Empty;
                    userData.RoomName   = string.Empty;
                    userData.Password   = 0;
                    userData.IsDrawing  = false;
                    userData.Points     = 0;
                    userData.Host       = false;

                    // if player was in lobby
                    if (oldState == State.Lobby || oldState == State.LobbyReady)
                    {
                        this.sendLobbyListToAll(roomInfo);
                    }

                    // if player was in game
                    if (oldState == State.Game)
                    {
                        // check if only one player is left in game
                        var playersInGame = this.getPlayersInGame(roomInfo);
                        if (playersInGame.Count() == 1)
                        {
                            // kick last player in game
                            playersInGame.First().send(new KickedNoMorePlayer());
                        }
                        else if (playersInGame.Count() > 1)
                        {
                            // update ranklist for players in game
                            this.sendRankListToAll(roomInfo);
                        }
                    }

                    // update and send roomlist
                    this.sendRoomListToAll();
                }
                else if (userData.State == State.RoomCreation)
                {
                    string randomRoomName = string.Empty;

                    // generate random room name
                    // TODO: better performance when checking host boolean first
                    int i = 1000;
                    while (Server.Clients.Count(c => (c.UserData as ClientUserData).RoomName == (randomRoomName = $"Room{Server.rand.Next(0, 999).ToString().PadLeft(3, '0')}") && (c.UserData as ClientUserData).Host) > 0 && i-- > 0)
                    {
                    }

                    client.send(new RandomRoomName {
                        Name = randomRoomName
                    });
                }
                else if (userData.State == State.LobbyReady || userData.State == State.Lobby)
                {
                    if (userData.PlayerName == string.Empty)
                    {
                        string randomPlayerName = string.Empty;

                        // generate random room name

                        var players = this.getPlayers(roomInfo);
                        while (players.Any(p =>
                        {
                            return((p.UserData as ClientUserData).PlayerName == (randomPlayerName = $"Player{Server.rand.Next(0, 999).ToString().PadLeft(3, '0')}"));
                        }))
                        {
                        }

                        userData.PlayerName = randomPlayerName;

                        client.send(new RandomPlayerName {
                            Name = randomPlayerName
                        });

                        // update and send lobbylist
                        this.sendLobbyListToAll(roomInfo);
                    }
                    else
                    {
                        string newPlayerName = changeState.Data as string;

                        // check if any player has already the same name
                        int playerWithSameName = Server.Clients.Count(c => c.UserData != null && c != client && (c.UserData as ClientUserData).RoomName == userData.RoomName && (c.UserData as ClientUserData).PlayerName == newPlayerName);

                        if (playerWithSameName > 0)
                        {
                            client.send(new Error {
                                Job = Job.NameChange
                            });
                        }
                        else
                        {
                            // name is free and will be used
                            userData.PlayerName = newPlayerName;

                            if (userData.Host)
                            {
                                client.send(new Success {
                                    Job = Job.NameChange
                                });
                            }
                            else
                            {
                                bool hostIsPlaying = Server.Clients.Count(c => c.UserData != null && (c.UserData as ClientUserData).RoomName == userData.RoomName && (c.UserData as ClientUserData).Host && (c.UserData as ClientUserData).State == State.Game) > 0;

                                client.send(new Success {
                                    Job = hostIsPlaying ? Job.GameStart : Job.NameChange
                                });
                            }

                            // update and send lobbylist
                            this.sendLobbyListToAll(roomInfo);
                        }
                    }

                    // update and send roomlist
                    this.sendRoomListToAll();
                }
                else if (userData.State == State.Game)
                {
                    if (userData.Host)
                    {
                        // send ranklist
                        this.sendRankListToAll(roomInfo);

                        // tell other players that the game starts
                        var players = this.getPlayersInLobbyAndReady(roomInfo);
                        this.sendObjectToPlayers(players, new StartGame());
                    }
                    else
                    {
                        // check if player joins later
                        if (this.rooms.Exists(c => c.Name == userData.RoomName && c.Started))
                        {
                            // this player joins later
                            // send ranklist
                            this.sendRankListToAll(roomInfo);

                            // get current drawer and send drawing request
                            var currentDrawer = this.getCurrentDrawer(roomInfo);
                            if (currentDrawer != null)
                            {
                                currentDrawer.send(new DrawingRequest());
                            }
                        }
                        else
                        {
                            // count players in lobby
                            var playersInLobbyCount = this.getPlayersInLobbyAndReady(roomInfo).Count();

                            // start game when all players are in the game
                            if (playersInLobbyCount == 0)
                            {
                                // start game for the first time
                                roomInfo.Started = true;

                                // start first round
                                this.startRound(roomInfo);
                            }
                        }
                    }

                    this.sendRoomListToAll();
                }

                this.updateCountLabels();
            }
            else if (obj is CreateRoom)
            {
                CreateRoom createRoom = obj as CreateRoom;
                this.createRoom(client, createRoom);
            }
            else if (obj is JoinRoom)
            {
                JoinRoom joinRoom = obj as JoinRoom;
                this.joinRoom(client, joinRoom);
            }
            else if (obj is StartGame)
            {
                int playerCount      = this.getPlayers(roomInfo).Count();
                int playerCountReady = this.getPlayersInLobbyAndReady(roomInfo).Count();
                if (playerCount != playerCountReady || playerCount < 2)
                {
                    client.send(new Error {
                        Job = Job.GameStart
                    });
                }
                else
                {
                    client.send(new Success {
                        Job = Job.GameStart
                    });
                }
            }
            else if (obj is ChatMessage)
            {
                var chatMessage = obj as ChatMessage;
                chatMessage.PlayerName = userData.PlayerName;

                // get all clients in the same room and that are playing
                var players = this.getPlayersInGame(roomInfo);

                // check if entered word is equal to searched word
                bool foundWord = (roomInfo.CurrentWord.ToLower() == chatMessage.Text.ToLower());

                if (foundWord && (roomInfo.RoundInfo.PlayerTimes.ContainsKey(userData.PlayerName) || userData.IsDrawing))
                {
                    client.send(new WhatDoYouWantInfo());
                }
                else
                {
                    var foundWordInfo = foundWord ? new FoundWordInfo {
                        PlayerName = userData.PlayerName
                    } : null;

                    if (foundWord)
                    {
                        // give points
                        roomInfo.RoundInfo.PlayerTimes.Add(userData.PlayerName, 500 * ((players.Count() - 1) - roomInfo.RoundInfo.PlayerTimes.Count));
                    }

                    foreach (var player in players)
                    {
                        if (foundWord)
                        {
                            player.send(foundWordInfo);
                        }
                        else
                        {
                            player.send(chatMessage);
                        }
                    }

                    // check if this is the last player that found the word
                    if (foundWord && roomInfo.RoundInfo.PlayerTimes.Count == players.Count() - 1)
                    {
                        // end round
                        roomInfo.RoundInfo.WordUpdateTimer.Stop();

                        // send revealed word
                        string revealedWord    = string.Join(" ", roomInfo.CurrentWord);
                        var    choosedWordInfo = new ChoosedWordInfo {
                            Word = revealedWord
                        };

                        this.sendObjectToPlayers(players, choosedWordInfo);

                        this.nextDrawer(roomInfo);
                    }
                }
            }
            else if (obj is Drawing)
            {
                // get every player in the same room, except drawer
                var players = this.getPlayersInGameExceptDrawer(roomInfo);
                this.sendObjectToPlayers(players, obj);
            }
            else if (obj is ChoosedWord)
            {
                var choosenWord = obj as ChoosedWord;

                roomInfo.CurrentWord = choosenWord.Word;
                roomInfo.CurrentWordRevealed.Clear();

                // store choosen word to list with choosen words => solution is a bit ugly
                roomInfo.ChoosenWordIndices.Add(this.wordList.IndexOf(this.wordList.First(w => w.Word == choosenWord.Word)));

                var timer = roomInfo.RoundInfo.WordUpdateTimer = new Timer();
                timer.Interval = (int)((this.roundDuration * 1000.0) / choosenWord.Word.Length);
                timer.Tick    += (s2, e2) => this.revealCharOfWord(s2, roomInfo);
                this.revealCharOfWord(timer, roomInfo);
                timer.Start();
            }
            else if (obj is KickedByHost)
            {
                var playerName = (obj as KickedByHost).PlayerName;
                var player     = this.getPlayerByName(playerName);
                player?.send(obj);
            }
        }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     createRoom = GameObject.Find("Player").GetComponent <CreateRoom>();
     audio      = gameObject.GetComponent <AudioSource>();
     Debug.Log("Collision");
 }
    public override IMessage OnHotelBroadCast(ByteString msg)
    {
        HotelBroadcast broadcast = new HotelBroadcast();

        ByteUtils.ByteStringToObject(broadcast, msg);
        Logger.Info("HotelBroadcast start, userID:{0} gameID:{1} roomID:{2} cpProto:{3}", broadcast.UserID, broadcast.GameID, broadcast.RoomID, broadcast.CpProto.ToStringUtf8());

        HotelBroadcastAck broadcastAck = new HotelBroadcastAck()
        {
            UserID = broadcast.UserID, Status = (UInt32)ErrorCode.Ok
        };

        PushToHotelMsg pushMsg = new PushToHotelMsg()
        {
            PushType = PushMsgType.UserTypeAll,
            GameID   = broadcast.GameID,
            RoomID   = broadcast.RoomID,
            CpProto  = broadcast.CpProto,
        };

        pushMsg.DstUids.Add(broadcast.UserID);

        PushToHotel(broadcast.RoomID, pushMsg);

        //测试主动推送给MVS的两个消息
        string str = broadcast.CpProto.ToStringUtf8();

        Logger.Info("HotelBroadcast, str = {0}", str);

        String[] result = str.Split("|");
        if (result.Length > 1)
        {
            if (result[0] == "joinover")
            {
                String[] param = result[1].Split(",");
                if (param.Length > 1)
                {
                    UInt64 roomID = UInt64.Parse(param[0]);
                    UInt32 gameID = UInt32.Parse(param[1]);
                    PushJoinOver(roomID, gameID);
                }
            }
            else if (result[0] == "joinopen")
            {
                PushJoinOpen(broadcast.RoomID, broadcast.GameID);
            }
            else if (result[0] == "kickplayer")
            {
                String[] param = result[1].Split(",");
                if (param.Length > 2)
                {
                    UInt64 roomID = UInt64.Parse(param[0]);
                    UInt32 destID = UInt32.Parse(param[1]);
                    PushKickPlayer(roomID, destID);
                }
            }
            else if (result[0] == "getRoomDetail")
            {
                String[] param = result[1].Split(",");
                if (param.Length > 1)
                {
                    UInt32 gameID = UInt32.Parse(param[0]);
                    UInt64 roomID = UInt64.Parse(param[1]);
                    PushGetRoomDetail(roomID, gameID, 2);
                }
            }
            else if (result[0] == "setRoomProperty")
            {
                ByteString roomProperty = Google.Protobuf.ByteString.CopyFromUtf8(result[1]);
                PushSetRoomProperty(broadcast.RoomID, broadcast.GameID, roomProperty);
            }
            else if (result[0] == "createRoom")
            {
                CreateRoom request = new CreateRoom()
                {
                    GameID   = broadcast.GameID,
                    Ttl      = 600,
                    RoomInfo = new RoomInfo()
                    {
                        RoomName     = "game server room",
                        MaxPlayer    = 2,
                        Mode         = 1,
                        CanWatch     = 1,
                        Visibility   = 1,
                        RoomProperty = Google.Protobuf.ByteString.CopyFromUtf8("hello"),
                    },
                    WatchSetting = new WatchSetting()
                    {
                        MaxWatch        = 3,
                        WatchPersistent = false,
                        WatchDelayMs    = 10 * 1000,
                        CacheTime       = 60 * 1000,
                    },
                };
                var reply = CreateRoom(request);
                Logger.Debug("create room request: {0}, reply: {1}", request, reply);
            }
            else if (result[0] == "touchRoom")
            {
                String[]  param   = result[1].Split(",");
                TouchRoom request = new TouchRoom()
                {
                    GameID = broadcast.GameID,
                    RoomID = UInt64.Parse(param[0]),
                    Ttl    = UInt32.Parse(param[1]),
                };
                var reply = TouchRoom(request);
                Logger.Debug("touch room request: {0}, reply: {1}", request, reply);
            }
            else if (result[0] == "destroyRoom")
            {
                DestroyRoom request = new DestroyRoom()
                {
                    GameID = broadcast.GameID,
                    RoomID = UInt64.Parse(result[1]),
                };
                var reply = DestroyRoom(request);
                Logger.Debug("destroy room request: {0}, reply: {1}", request, reply);
            }
            else if (result[0] == "setFrameSyncRate")
            {
                if (result.Length < 3)
                {
                    Logger.Error("set frame sync rate error: no cacheFrameMS");
                    return(new HotelBroadcastAck()
                    {
                        UserID = broadcast.UserID, Status = (UInt32)ErrorCode.BadRequest
                    });
                }

                var rate         = UInt32.Parse(result[1]);
                var cacheFrameMS = Int32.Parse(result[2]);
                SetFrameSyncRate(broadcast.RoomID, broadcast.GameID, rate, 1, cacheFrameMS);
                Logger.Debug("set frame sync rate: {0}", rate);
            }
            else if (result[0] == "getCacheData")
            {
                Int32 cacheFrameMS = Int32.Parse(result[1]);
                GetCacheData(broadcast.RoomID, broadcast.GameID, cacheFrameMS);
                Logger.Debug("get cache frame data: {0}", cacheFrameMS);
            }
            else if (result[0] == "frameBroadcast")
            {
                var cpProto = result[1];
                FrameBroadcast(broadcast.RoomID, broadcast.GameID, ByteString.CopyFromUtf8(cpProto), 2);
                Logger.Info("frame broadcast: {0}", cpProto);
            }
            else if (result[0] == "metric")
            {
                if (result.Length >= 3)
                {
                    string      name  = result[1];
                    double      value = double.Parse(result[2]);
                    MetricPoint point = new MetricPoint()
                    {
                        Name  = name,
                        Value = value,
                        Attr  = MetricAttr.Custom,
                    };
                    ReportAck ack = ReportMetrics(point);
                    Logger.Info("Set matric response: {0}", ack);
                }
            }
        }

        Logger.Info("HotelBroadcast end, userID:{0} gameID:{1} roomID:{2} cpProto:{3}", broadcast.UserID, broadcast.GameID, broadcast.RoomID, broadcast.CpProto.ToStringUtf8());

        return(broadcastAck);
    }
 public CreateRoomAck CreateRoom(CreateRoom request)
 {
     return(roomManger.CreateRoom(request));
 }
Beispiel #6
0
 void Awake()
 {
     Instance = this;
 }
        private void ReceiveMessages()
        {
            strReader = new StreamReader(tcpClient.GetStream());
            string numCardsInSet = "0";

            // While we are successfully connected, read incoming lines from the server
            while (isConnectedToServer)
            {
                string   serverResponse = strReader.ReadLine();
                string[] data           = serverResponse.Split(';');


                if (data[0].Equals("AVALIABLE_NICK"))
                {
                    // Console.WriteLine("Test = nick was avaliable. OK");
                }
                if (data[0].Equals("LOGIN_FAILED"))
                {
                    string message = data[1];
                    //ZMIENIC NA CONNECT
                    _viewConnect.ShowInformation(message, "Login failed");
                    _viewConnect.Hide();


                    Connect con = new Connect();
                    con.Visible = false;

                    MenuAfterLogin cojg = new MenuAfterLogin();
                    cojg.Visible = false;

                    Game game = new Game();
                    game.Visible = false;

                    CreateRoom createRoom = new CreateRoom();
                    createRoom.Visible = false;

                    JoinRoom joinRoom = new JoinRoom();
                    joinRoom.Visible = false;

                    Ranking ranking = new Ranking();
                    ranking.Visible = false;


                    ConnectController controller = new ConnectController(con, cojg, createRoom, joinRoom, ranking, game);


                    controller.LoadViewConnect(con);

                    con.ShowDialog();
                }

                if (data[0].Equals("WRONG_NICK"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Wrong nick");


                    Connect        con  = new Connect();
                    MenuAfterLogin cojg = new MenuAfterLogin();
                    Game           game = new Game();

                    CreateRoom createRoom = new CreateRoom();

                    JoinRoom joinRoom = new JoinRoom();

                    Ranking ranking = new Ranking();


                    ConnectController controller = new ConnectController(con, cojg, createRoom, joinRoom, ranking, game);
                    controller.LoadViewConnect(con);
                    con.ShowDialog();
                    _viewConnect.Hide();
                    Console.WriteLine("od nowa");
                    _viewGame.ShowInformation(message, "Wrong nick");

                    _viewConnect.SetClientMessage("[Log]:" + message);
                }



                if (data[0].Equals("INCOMING_MSG"))
                {
                    string source  = data[1];
                    string message = data[2];
                    _viewGame.SetClientMessage(source + ": " + message);
                }
                if (data[0].Equals("INCOMING_NUM_OF_PLAYERS"))
                {
                    string message = data[1];
                }
                if (data[0].Equals("INCOMING_SYMBOLS_NAMES"))
                {
                    string message = data[1];
                    cards.PathToImages = message;
                }


                if (data[0].Equals("ROOM_FOUND"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Room found");

                    _viewGame.SetClientMessage("[Log]:" + message);
                }

                if (data[0].Equals("ROOM_NOT_FOUND"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Room not found");
                }

                if (data[0].Equals("ROOM_FULL"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Room full");
                }


                if (data[0].Equals("START_GAME"))
                {
                    string message = data[1];

                    _viewGame.ShowInformation(message, "Start game!");


                    _viewGame.SetClientMessage("[Log]:" + message);
                }
                if (data[0].Equals("WAITING"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Waiting...");

                    _viewGame.SetClientMessage("[Log]:" + message);
                }

                if (data[0].Equals("MAIN_CARD"))
                {
                    if (data.Length == 9)
                    {
                        mainCard8(data);
                    }
                    if (data.Length == 7)
                    {
                        mainCard6(data);
                    }
                }


                if (data[0].Equals("PLAYER_CARD"))
                {
                    if (data.Length == 9)
                    {
                        symbols8(data);
                    }
                    if (data.Length == 7)
                    {
                        symbols6(data);
                    }
                }
                if (data[0].Equals("NUM_CARDS_IN_SET"))
                {
                    string message = data[1];
                    numCardsInSet = message;
                }


                if (data[0].Equals("NUM_CURRENT_CARD"))
                {
                    string message = data[1];
                    string text    = message + "/" + numCardsInSet;
                    _viewGame.NumCurrentCard(text);
                }

                if (data[0].Equals("LAST_NICK"))
                {
                    string message = data[1];
                    _viewGame.LastNick(message);
                }

                if (data[0].Equals("BAN"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Ban!");
                    _viewGame.SetClientMessage(message);
                    _viewGame.Ban();
                }
                if (data[0].Equals("UNBAN"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Unban");
                    _viewGame.SetClientMessage(message);
                    _viewGame.Unban();
                }
                if (data[0].Equals("WIN"))
                {
                    string message = data[1];
                    _viewGame.ShowInformation(message, "Win!");

                    _viewGame.SetClientMessage(message);
                    _viewGame.Win();
                }


                if (data[0].Equals("ROOM_LIST"))
                {
                    string message = data[1] + data[2];
                    _viewJoinRoom.RoomList(message);
                }

                if (data[0].Equals("STATUS_CLEAR"))
                {
                    string nick   = "Nick";
                    string status = "Status";
                    int    a      = 150;
                    int    b      = 56;

                    _viewGame.StatusClear(nick, status, a, b);
                }

                if (data[0].Equals("ROOM_CLEAR"))
                {
                    _viewJoinRoom.Clear();
                }

                if (data[0].Equals("STATUS_PLAYERS"))
                {
                    string col1 = data[1];
                    string col2 = data[2] + "/" + data[3];
                    _viewGame.StatusPlayers(col1, col2);
                }
                if (data[0].Equals("RANKING_ROW"))
                {
                    string col1 = data[1];
                    string col2 = data[2];
                    string col3 = data[3];

                    _viewRanking.AddRowRanking(col1, col2, col3);
                }

                if (data[0].Equals("RANKING_ROW_LOWER"))
                {
                    string col1 = data[1];
                    string col2 = data[2];
                    string col3 = data[3];

                    _viewRanking.AddRowRankingLower(col1, col2, col3);
                }



                _viewGame.AutoscrollingList();
            }
        }
Beispiel #8
0
        public async Task <(Room Room, HttpStatusCode StatusCode)> CreateRoom(int propertyId, CreateRoom room)
        {
            using (var content = new StringContent(JsonConvert.SerializeObject(room), Encoding.UTF8, "application/json"))
            {
                var response = await Client.PostAsync($"properties/{propertyId}/room", content);

                return(SerializationHelpers.GetEntityFromStream <Room>(await response.Content.ReadAsStreamAsync()), response.StatusCode);
            }
        }
Beispiel #9
0
 private void OnEnable()
 {
     _target          = (CreateRoom)target;
     roomObjContainer = GameObject.Find(roomObjGameObj);
 }
Beispiel #10
0
        public void AddNewAccount(string serveripTextbox, string portTextbox, string userNameTextbox, string passwordTextbox, string emailTextbox, string yearComboBox, string genderComboBox, string captchaTextbox)
        {
            string connectionEstablish;

            connectionEstablish = "CREATE_ACCOUNT;" + userNameTextbox + ";" + passwordTextbox + ";" + emailTextbox + ";" + yearComboBox + ";" + genderComboBox;


            tcpClient = new TcpClient();
            tcpClient.Connect(serveripTextbox, int.Parse(portTextbox));
            isConnectedToServer = true;
            strWritter          = new StreamWriter(tcpClient.GetStream());
            strWritter.WriteLine(connectionEstablish);
            strWritter.Flush();


            Console.WriteLine("nowy Connection");

            incomingMessageHandler = new Thread(() => ReceiveMessages());
            incomingMessageHandler.IsBackground = true;
            incomingMessageHandler.Start();

            int interval = 3000;


            while (!ACCOUNT_CREATED_SUCCESFULLY)

            {
                Console.WriteLine("spie 3 sek: ");
                Thread.Sleep(interval);
                if (ACCOUNT_CREATED_SUCCESFULLY == true)
                {
                    Console.WriteLine("JEST JUZ OK, ZAMYKAMY!");

                    SaveSettings();

                    ConnectController c = new ConnectController();


                    Connect        con  = new Connect();
                    MenuAfterLogin cojg = new MenuAfterLogin();
                    Game           game = new Game();

                    CreateRoom createRoom = new CreateRoom();

                    JoinRoom joinRoom = new JoinRoom();

                    Ranking ranking = new Ranking();


                    ConnectController controller = new ConnectController(con, cojg, createRoom, joinRoom, ranking, game);
                    controller.LoadViewConnect(con);
                    con.ShowDialog();

                    _view.Hide();
                    _view.Close();
                    _view.DisposeForm();

                    Console.WriteLine(ACCOUNT_CREATED_SUCCESFULLY + "jest just tru!!");
                }
                Console.WriteLine("ja zyje");
            }
        }
Beispiel #11
0
        private void ini()
        {
            //login
            mD[(int)CmdId.LoginRsp] = (He header) => {
                LoginRsp rsp = (LoginRsp)LoginRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LoginRsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.LogoutRsp] = (He header) => {
                var rsp = (LogoutRsp)LogoutRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LogoutRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mE[(int)CmdId.LoginReq] = (object[] arguments) => {
                u = (uint)arguments[1];
                LoginReq req = new LoginReq();
                req.Token    = MD5.MD5Encrypt((string)arguments[2]);
                req.GameID   = (uint)arguments[3];
                req.AppKey   = (string)arguments[4];
                req.DeviceID = (string)arguments[5];
                req.SdkVer   = "3";

                req.Sign = MD5.MD5Encrypt(string.Format("{0}&UserID={1}&GameID={2}&VersionSdk={3}&{4}", req.AppKey,
                                                        u, req.GameID, 3, req.Token));
                return(fHe(req.ToByteArray(), (int)arguments[0], true));
            };

            mE[(int)CmdId.LogoutReq] = (object[] arguments) => {
                return(fHe(StringUtil.toUtf8Array((string)arguments[1]), (int)arguments[0]));
            };


            //heartbeat

            mE[(int)CmdId.HeartBeatReq] = (object[] arguments) => {
                HeartbeatReq req = new HeartbeatReq();
                req.GameID = (uint)arguments[1];
                req.RoomID = (ulong)arguments[2];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.HeartBeatReq] = (He header) => {
                return(header);
            };

            //hotel heartbeat
            mE[(int)SDKHotelCmdID.HeartbeatCmdid] = (object[] arguments) => {
                Heartbeat req = new Heartbeat();
                req.GameID = (uint)arguments[1];
                req.RoomID = (ulong)arguments[2];
                req.UserID = (uint)arguments[3];

                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)SDKHotelCmdID.HeartbeatAckCmdid] = (He header) => {
                HeartbeatAck rsp = (HeartbeatAck)HeartbeatAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("rsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };



            //createRoom
            mE[(int)CmdId.CreateRoomReq] = (object[] arguments) => {
                MsRoomInfo p = (MsRoomInfo)arguments[1];

                PlayerInfo pi = new PlayerInfo();
                pi.UserID      = p.userID;
                pi.UserProfile = tbs(p.userProfile);


                RoomInfo ri = new RoomInfo();
                ri.MaxPlayer    = p.maxPlayer;
                ri.CanWatch     = p.canWatch;
                ri.Mode         = p.mode;
                ri.Visibility   = p.visibility;
                ri.RoomName     = p.roomName;
                ri.RoomProperty = tbs(p.roomProperty);

                CreateRoom req = new CreateRoom();
                req.PlayerInfo   = pi;
                req.RoomInfo     = ri;
                req.GameID       = p.gameID;
                req.WatchSetting = p.watchSetting;


                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.CreateRoomRsp] = (He header) => {
                CreateRoomRsp rsp = (CreateRoomRsp)CreateRoomRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("CreateRoomRsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };


            //joinRoom
            mE[(int)CmdId.JoinRoomReq] = (object[] arguments) => {
                MsRoomInfo p = (MsRoomInfo)arguments[1];

                PlayerInfo pi = new PlayerInfo();
                pi.UserID      = p.userID;
                pi.UserProfile = tbs(p.userProfile);


                RoomInfo ri = new RoomInfo();
                ri.MaxPlayer  = p.maxPlayer;
                ri.CanWatch   = p.canWatch;
                ri.Mode       = p.mode;
                ri.Visibility = p.visibility;
                ri.RoomID     = p.roomID;

                JoinRoomReq req = new JoinRoomReq();
                req.PlayerInfo   = pi;
                req.RoomInfo     = ri;
                req.GameID       = p.gameID;
                req.JoinType     = p.joinType;
                req.CpProto      = tbs(p.userProfile);
                req.WatchSetting = p.watchSetting;
                var tags = p.tags;
                if (tags != null)
                {
                    foreach (var k in tags.Keys)
                    {
                        var tag = new keyValue();
                        tag.Key   = k;
                        tag.Value = tags[k];
                        req.Tags.Add(tag);
                    }
                }

                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.JoinRoomRsp] = (He header) => {
                JoinRoomRsp rsp = (JoinRoomRsp)JoinRoomRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinRoomRsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.NoticeUserJoinReq] = (He header) => {
                NoticeJoin rsp = (NoticeJoin)NoticeJoin.Descriptor.Parser.ParseFrom(header.data);
                Log.d("NoticeUserJoinReq.UserID:{0}->{1}", rsp.User.UserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            mE[(int)CmdId.LeaveRoomReq] = (object[] arguments) => {
                LeaveRoomReq p = new LeaveRoomReq();
                p.GameID  = MVS.GameID;
                p.UserID  = MVS.UserID;
                p.RoomID  = MVS.RoomID;
                p.CpProto = ByteString.CopyFrom(StringUtil.toUtf8Array((string)arguments[1]));
                return(fHe(p.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.LeaveRoomRsp] = (He header) => {
                LeaveRoomRsp rsp = (LeaveRoomRsp)LeaveRoomRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LeaveRoomRsp.UserID:{0}->{1}", rsp.UserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.NoticeUserLeaveReq] = (He header) => {
                NoticeLeave rsp = (NoticeLeave)NoticeLeave.Descriptor.Parser.ParseFrom(header.data);
                Log.d("NoticeUserLeave.UserID:{0}->{1}", rsp.UserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //hotel
            mE[(int)SDKHotelCmdID.CheckinCmdid] = (object[] arguments) => {
                var pkg = new CheckIn();
                pkg.GameID = (uint)arguments[4];
                pkg.RoomID = ((RoomInfo)arguments[2]).RoomID;
                pkg.UserID = (uint)arguments[3];
                var bookInfo = (BookInfo)arguments[1];
                pkg.BookID = bookInfo.BookID;
                pkg.Key    = bookInfo.BookKey;

                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)SDKHotelCmdID.CheckinAckCmdid] = (He header) => {
                CheckInAck rsp = (CheckInAck)CheckInAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("CheckInAck.BookID:{0}->{1}", rsp.BookID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //sendEvent
            mE[(int)SDKHotelCmdID.BroadcastCmdid] = (object[] arguments) => {
                var pkg = new Broadcast();
                pkg.RoomID = (ulong)arguments[1];
                uint[] dstUids = (uint[])arguments[2];
                foreach (var i in dstUids)
                {
                    pkg.DstUids.Add(i);
                }

                // 低8位 由 0-3  | destType |msgType 组合 0000|00|00
                uint priority = 2;
                uint flag     = (uint)(((priority & 0x0F) << 4) + (((int)arguments[3] & 0x03) << 2) + ((int)arguments[4] & 0x03));
                pkg.Flag = flag;

                pkg.CpProto = ByteString.CopyFrom((byte[])arguments[5]);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)SDKHotelCmdID.BroadcastAckCmdid] = (He header) => {
                BroadcastAck rsp = (BroadcastAck)BroadcastAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("BroadcastAck.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKHotelCmdID.NotifyCmdid] = (He header) => {
                Notify rsp = (Notify)Notify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("Notify.SrcUid:{0}->data.len:{1}", rsp.SrcUid, rsp.CpProto.Length);
                header.deserialization = rsp;
                return(header);
            };

            //FrameSync
            mE[(int)SDKHotelCmdID.FrameBroadcastCmdid] = (object[] arguments) => {
                var pkg = new FrameBroadcast();
                pkg.RoomID    = (ulong)arguments[1];
                pkg.Priority  = (uint)arguments[2];
                pkg.CpProto   = ByteString.CopyFrom((byte[])arguments[3]);
                pkg.Operation = (int)arguments[4];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };
            mE[(int)SDKHotelCmdID.SetFrameSyncRateCmdid] = (object[] arguments) => {
                var pkg = new SetFrameSyncRate();
                pkg.GameID       = (uint)arguments[1];
                pkg.RoomID       = (ulong)arguments[2];
                pkg.Priority     = (uint)arguments[3];
                pkg.FrameRate    = (uint)arguments[4];
                pkg.EnableGS     = (uint)arguments[5];
                pkg.CacheFrameMS = (int)arguments[6];
                pkg.FrameIdx     = 1;
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)SDKHotelCmdID.FrameBroadcastAckCmdid] = (He header) => {
                FrameBroadcastAck rsp = (FrameBroadcastAck)FrameBroadcastAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("FrameBroadcastAck.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKHotelCmdID.FrameDataNotifyCmdid] = (He header) => {
                FrameDataNotify rsp = (FrameDataNotify)FrameDataNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("FrameDataNotify.SrcUid:{0}->data.len:{1}", rsp.SrcUid, rsp.CpProto.Length);
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKHotelCmdID.FrameSyncNotifyCmdid] = (He header) => {
                FrameSyncNotify rsp = (FrameSyncNotify)FrameSyncNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("FrameSyncNotify.LastIdx:{0}->TimeStamp:{1}", rsp.LastIdx, rsp.TimeStamp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)SDKHotelCmdID.SetFrameSyncRateAckCmdid] = (He header) => {
                SetFrameSyncRateAck rsp =
                    (SetFrameSyncRateAck)SetFrameSyncRateAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetFrameSyncRateAck.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKHotelCmdID.SetFrameSyncRateNotifyCmdid] = (He header) => {
                SetFrameSyncRateNotify rsp =
                    (SetFrameSyncRateNotify)SetFrameSyncRateNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetFrameSyncRateNotify.FrameRate:{0}->{1}", rsp.FrameRate, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //turn on/off for join room
            mE[(int)CmdId.JoinOpenReq] = (object[] arguments) => {
                var pkg = new JoinOpenReq();
                pkg.GameID  = (uint)arguments[1];
                pkg.RoomID  = (ulong)arguments[2];
                pkg.UserID  = (uint)arguments[3];
                pkg.CpProto = ByteString.CopyFrom((byte[])arguments[4]);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };
            mE[(int)CmdId.JoinOverReq] = (object[] arguments) => {
                var pkg = new JoinOverReq();
                pkg.GameID  = (uint)arguments[1];
                pkg.RoomID  = (ulong)arguments[2];
                pkg.UserID  = (uint)arguments[3];
                pkg.CpProto = ByteString.CopyFrom((byte[])arguments[4]);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.JoinOverRsp] = (He header) => {
                JoinOverRsp rsp = (JoinOverRsp)JoinOverRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinOverRsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.JoinOpenRsp] = (He header) => {
                JoinOpenRsp rsp = (JoinOpenRsp)JoinOpenRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinOpenRsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.JoinOverNotify] = (He header) => {
                JoinOverNotify rsp = (JoinOverNotify)JoinOverNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinOverNotify.UserID:{0}->{1}", rsp.SrcUserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.JoinOpenNotify] = (He header) => {
                JoinOpenNotify rsp = (JoinOpenNotify)JoinOpenNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinOpenNotify.UserID:{0}->{1}", rsp.UserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //SetRoomProperty
            mE[(int)CmdId.SetRoomPropertyReq] = (object[] arguments) => {
                var pkg = new SetRoomPropertyReq();
                pkg.GameID       = (uint)arguments[1];
                pkg.RoomID       = (ulong)arguments[2];
                pkg.UserID       = (uint)arguments[3];
                pkg.RoomProperty = ByteString.CopyFrom((byte[])arguments[4]);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.SetRoomPropertyRsp] = (He header) => {
                SetRoomPropertyRsp rsp =
                    (SetRoomPropertyRsp)SetRoomPropertyRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetRoomPropertyRsp.UserID:{0}->{1}", rsp.UserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.NoticeRoomProperty] = (He header) => {
                NoticeRoomProperty rsp =
                    (NoticeRoomProperty)NoticeRoomProperty.Descriptor.Parser.ParseFrom(header.data);
                Log.d("NoticeRoomProperty.UserID:{0}->{1}", rsp.UserID, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //getRoomDetail
            mE[(int)CmdId.GetRoomDetailReq] = (object[] arguments) => {
                var pkg = new GetRoomDetailReq();
                pkg.GameID = (uint)arguments[1];
                pkg.RoomID = (ulong)arguments[2];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.GetRoomDetailRsp] = (He header) => {
                GetRoomDetailRsp rsp = (GetRoomDetailRsp)GetRoomDetailRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("GetRoomDetailRsp:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //getRoomList
            mE[(int)CmdId.RoomListExReq] = (object[] arguments) => {
                var pkg    = new GetRoomListExReq();
                var filter = (MsRoomFilter)arguments[2];

                var roomFilter = new RoomFilter();
                roomFilter.MaxPlayer     = (filter.maxPlayer);
                roomFilter.Mode          = filter.mode;
                roomFilter.Full          = filter.full;
                roomFilter.CanWatch      = (filter.canWatch);
                roomFilter.RoomProperty  = ByteString.CopyFrom(StringUtil.toUtf8Array(filter.roomProperty));
                roomFilter.State         = filter.state;
                roomFilter.GetSystemRoom = filter.getSystemRoom;

                pkg.GameID     = (uint)arguments[1];
                pkg.RoomFilter = roomFilter;
                pkg.Sort       = (filter.sort);
                pkg.Order      = (filter.order);
                pkg.PageNo     = (filter.pageNo);
                pkg.PageSize   = (filter.pageSize);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.RoomListExRsp] = (He header) => {
                GetRoomListExRsp rsp = (GetRoomListExRsp)GetRoomListExRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("GetRoomDetailRsp:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //NetWorkState
            mD[(int)CmdId.NoticeRoomNetworkState] = (He header) => {
                RoomNetworkStateNotify rsp =
                    (RoomNetworkStateNotify)RoomNetworkStateNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("RoomNetworkStateNotify:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.NoticeTeamNetworkState] = (He header) => {
                TeamNetworkStateNotify rsp =
                    (TeamNetworkStateNotify)TeamNetworkStateNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("TeamNetworkStateNotify:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };


            //watchRoomList
            mE[(int)CmdId.GetWatchRoomsReq] = (object[] arguments) => {
                var pkg    = new GetWatchRoomsReq();
                var filter = (MsRoomFilter)arguments[2];


                var roomFilter = new RoomFilter();
                roomFilter.MaxPlayer     = (filter.maxPlayer);
                roomFilter.Mode          = filter.mode;
                roomFilter.Full          = filter.full;
                roomFilter.CanWatch      = (filter.canWatch);
                roomFilter.RoomProperty  = ByteString.CopyFrom(StringUtil.toUtf8Array(filter.roomProperty));
                roomFilter.State         = filter.state;
                roomFilter.GetSystemRoom = filter.getSystemRoom;

                pkg.GameID     = (uint)arguments[1];
                pkg.RoomFilter = roomFilter;
                pkg.Sort       = (filter.sort);
                pkg.Order      = (filter.order);
                pkg.PageNo     = (filter.pageNo);
                pkg.PageSize   = (filter.pageSize);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.GetWatchRoomsRsp] = (He header) => {
                GetWatchRoomsRsp rsp = (GetWatchRoomsRsp)GetWatchRoomsRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("GetWatchRoomsRsp:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //joinWatch
            mE[(int)CmdId.JoinWatchRoomReq] = (object[] arguments) => {
                var p   = (MsRoomInfo)arguments[1];
                var req = new JoinWatchRoomReq();
                req.GameID      = p.gameID;
                req.RoomID      = p.roomID;
                req.UserID      = p.userID;
                req.UserProfile = tbs(p.userProfile);
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.JoinWatchRoomRsp] = (He header) => {
                var rsp = (JoinWatchRoomRsp)JoinWatchRoomRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinWatchRoomRsp.Status:{0}->{1}", rsp.Status, rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.JoinWatchRoomNotify] = (He header) => {
                var rsp = (JoinWatchRoomNotify)JoinWatchRoomNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinWatchRoomNotify:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //leaveWatch
            mE[(int)CmdId.LeaveWatchRoomReq] = (object[] arguments) => {
                var p = new LeaveWatchRoomReq();
                p.GameID  = MVS.GameID;
                p.UserID  = MVS.UserID;
                p.RoomID  = MVS.RoomID;
                p.CpProto = ByteString.CopyFrom(StringUtil.toUtf8Array((string)arguments[1]));
                return(fHe(p.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.LeaveWatchRoomRsp] = (He header) => {
                var rsp = (LeaveWatchRoomRsp)LeaveWatchRoomRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LeaveWatchRoomRsp:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.LeaveWatchRoomNotify] = (He header) => {
                var rsp = (LeaveWatchRoomNotify)LeaveWatchRoomNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LeaveWatchRoomNotify:{0}->", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };

            //WatchCheckIn
            mE[(int)SDKWatchCmdID.EnterLiveRoomCmdid] = (object[] arguments) => {
                var pkg = new EnterLiveRoom();
                pkg.GameID = (uint)arguments[4];
                pkg.RoomID = (ulong)arguments[2];
                pkg.UserID = (uint)arguments[3];
                var bookInfo = (BookInfo)arguments[1];
                pkg.BookID = bookInfo.BookID;
                pkg.Ticket = bookInfo.BookKey;
                pkg.SetID  = (uint)arguments[5];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };
            mE[(int)SDKWatchCmdID.SetLiveOffsetCmdid] = (object[] arguments) => {
                var pkg = new SetLiveOffset();
                pkg.GameID   = (uint)arguments[1];
                pkg.RoomID   = (ulong)arguments[2];
                pkg.UserID   = (uint)arguments[3];
                pkg.OffsetMS = (int)arguments[4];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)SDKWatchCmdID.EnterLiveRoomAckCmdid] = (He header) => {
                var rsp = (EnterLiveRoomAck)EnterLiveRoomAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("EnterLiveRoomAck:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKWatchCmdID.EnterLiveRoomNotifyCmdid] = (He header) => {
                var rsp = (EnterLiveRoomNotify)EnterLiveRoomNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("EnterLiveRoomNotify:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKWatchCmdID.ExitLiveRoomNotifyCmdid] = (He header) => {
                var rsp = (ExitLiveRoomNotify)ExitLiveRoomNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("ExitLiveRoomNotify:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };


            mD[(int)SDKWatchCmdID.SetLiveOffsetAckCmdid] = (He header) => {
                var rsp = (SetLiveOffsetAck)SetLiveOffsetAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetLiveOffsetAck:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };


            //LiveBroadcast
            mE[(int)SDKWatchCmdID.LiveBroadcastCmdid] = (object[] arguments) => {
                var pkg = new LiveBroadcast();
                pkg.RoomID = (ulong)arguments[1];
                uint[] dstUids = (uint[])arguments[2];
                foreach (var i in dstUids)
                {
                    pkg.DstUids.Add(i);
                }

                // 低8位 由 0-3  | destType |msgType 组合 0000|00|00
                uint priority = 2;
                uint flag     = ((priority & 0x0F) << 4) + (((uint)arguments[3] & 0x03) << 2) + ((uint)arguments[4] & 0x03);
                pkg.Flag    = flag;
                pkg.CpProto = ByteString.CopyFrom((byte[])arguments[5]);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)SDKWatchCmdID.LiveBroadcastAckCmdid] = (He header) => {
                var rsp = (LiveBroadcastAck)LiveBroadcastAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LiveBroadcast:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKWatchCmdID.LiveBroadcastNotifyCmdid] = (He header) => {
                var rsp = (LiveBroadcastNotify)LiveBroadcastNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LiveBroadcastNotify:{0}", rsp.ToString());
                header.deserialization = rsp;
                return(header);
            };


            mD[(int)SDKWatchCmdID.LiveFrameDataNotifyCmdid] = (He header) => {
                var rsp = (LiveFrameDataNotify)LiveFrameDataNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LiveFrameDataNotify.{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKWatchCmdID.LiveFrameSyncNotifyCmdid] = (He header) => {
                var rsp = (LiveFrameSyncNotify)LiveFrameSyncNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LiveFrameSyncNotify:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //watch heart beat
            mE[(int)SDKWatchCmdID.LiveHeartbeatCmdid] = (object[] arguments) => {
                LiveHeartbeat req = new LiveHeartbeat();
                req.GameID = (uint)arguments[1];
                req.RoomID = (ulong)arguments[2];
                req.UserID = (uint)arguments[3];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)SDKWatchCmdID.LiveHeartbeatAckCmdid] = (He header) => {
                var rsp = (LiveHeartbeatAck)LiveHeartbeatAck.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LiveFrameSyncNotify:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)SDKWatchCmdID.LiveOverNotifyCmdid] = (He header) => {
                var rsp = (LiveOverNotify)LiveOverNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LiveOverNotify:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };


            //team - create
            mE[(int)CmdId.CreateTeamReq] = (arguments) => {
                PlayerInfo pi = new PlayerInfo();
                pi.UserID      = (uint)arguments[1];
                pi.UserProfile = tbs((string)arguments[2]);

                CreateTeamReq req = new CreateTeamReq();
                req.PlayerInfo = pi;
                req.GameID     = (uint)arguments[3];
                req.TeamInfo   = (TeamInfo)arguments[4];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.CreateTeamRsp] = (header) => {
                var rsp = (CreateTeamRsp)CreateTeamRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("CreateTeamRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };
            //team - join
            mE[(int)CmdId.JoinTeamReq] = (arguments) => {
                PlayerInfo pi = new PlayerInfo();
                pi.UserID      = (uint)arguments[1];
                pi.UserProfile = tbs((string)arguments[2]);

                JoinTeamReq req = new JoinTeamReq();
                req.PlayerInfo = pi;
                req.GameID     = (uint)arguments[3];
                req.TeamID     = (ulong)arguments[4];
                req.Password   = (string)arguments[5];
                req.JoinType   = (JoinTeamType)arguments[6];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.JoinTeamRsp] = (header) => {
                var rsp = (JoinTeamRsp)JoinTeamRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinTeamRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.JoinTeamNotify] = (He header) => {
                var rsp = (JoinTeamNotify)JoinTeamNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("JoinTeamNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team - leave
            mE[(int)CmdId.LeaveTeamReq] = (arguments) => {
                LeaveTeamReq req = new LeaveTeamReq();
                req.GameID = (uint)arguments[1];
                req.TeamID = (ulong)arguments[3];
                req.UserID = (uint)arguments[2];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.LeaveTeamRsp] = (header) => {
                var rsp = (LeaveTeamRsp)LeaveTeamRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LeaveTeamRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.LeaveTeamNotify] = (He header) => {
                var rsp = (LeaveTeamNotify)LeaveTeamNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("LeaveTeamNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team - match
            mE[(int)CmdId.TeamMatchReq] = (arguments) => {
                TeamMatchReq req = new TeamMatchReq();
                req.GameID = (uint)arguments[1];
                req.UserID = (uint)arguments[2];
                req.TeamID = (ulong)arguments[3];
                req.Cond   = (TeamMatchCond)arguments[4];

                MsRoomInfo p  = (MsRoomInfo)arguments[5];
                RoomInfo   ri = new RoomInfo();
                ri.RoomID       = p.roomID;
                ri.RoomName     = p.roomName;
                ri.MaxPlayer    = p.maxPlayer;
                ri.Mode         = p.mode;
                ri.CanWatch     = p.canWatch;
                ri.Visibility   = p.visibility;
                ri.RoomProperty = tbs(p.roomProperty);

                req.RoomInfo = ri;
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.TeamMatchRsp] = (header) => {
                var rsp = (TeamMatchRsp)TeamMatchRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("TeamMatchRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.TeamMatchStartNotify] = (He header) => {
                var rsp = (TeamMatchStartNotify)TeamMatchStartNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("TeamMatchStartNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };
            mD[(int)CmdId.TeamMatchResultNotify] = (He header) => {
                var rsp = (TeamMatchResultNotify)TeamMatchResultNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("TeamMatchResultNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team - cancel match
            mE[(int)CmdId.CancelTeamMatchReq] = (arguments) => {
                CancelTeamMatchReq req = new CancelTeamMatchReq();
                req.GameID  = (uint)arguments[1];
                req.UserID  = (uint)arguments[2];
                req.TeamID  = (ulong)arguments[3];
                req.CpProto = tbs((string)arguments[4]);
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.CancelTeamMatchRsp] = (header) => {
                var rsp = (CancelTeamMatchRsp)CancelTeamMatchRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("CancelTeamMatchRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.CancelTeamMatchNotify] = (header) => {
                var rsp = (CancelTeamMatchNotify)CancelTeamMatchNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("CancelTeamMatchNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team - kick match
            mE[(int)CmdId.KickTeamMemberReq] = (arguments) => {
                KickTeamMemberReq req = new KickTeamMemberReq();
                req.GameID    = (uint)arguments[1];
                req.UserID    = (uint)arguments[2];
                req.TeamID    = (ulong)arguments[3];
                req.CpProto   = tbs((string)arguments[4]);
                req.DstUserID = (uint)arguments[5];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.KickTeamMemberRsp] = (header) => {
                var rsp = (KickTeamMemberRsp)KickTeamMemberRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("KickTeamMemberRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.KickTeamMemberNotify] = (header) => {
                var rsp = (KickTeamMemberNotify)KickTeamMemberNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("KickTeamMemberNotify:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team sendEvent
            mE[(int)CmdId.SendTeamEventReq] = (arguments) => {
                var pkg = new SendTeamEventReq();
                pkg.TeamID = (ulong)arguments[1];
                uint[] dstUids = (uint[])arguments[2];
                foreach (var i in dstUids)
                {
                    pkg.DstUids.Add(i);
                }
                pkg.DstType = (TeamDstType)arguments[3];
                pkg.MsgType = (TeamMsgType)arguments[4];
                pkg.CpProto = ByteString.CopyFrom((byte[])arguments[5]);
                pkg.GameID  = (uint)arguments[6];
                pkg.UserID  = (uint)arguments[7];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.SendTeamEventRsp] = (header) => {
                var rsp = (SendTeamEventRsp)SendTeamEventRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SendTeamEventRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.SendTeamEventNotify] = (header) => {
                var rsp = (SendTeamEventNotify)SendTeamEventNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SendTeamEventNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team profile
            mE[(int)CmdId.SetTeamPropertyReq] = (arguments) => {
                var pkg = new SetTeamPropertyReq();
                pkg.GameID       = (uint)arguments[1];
                pkg.TeamID       = (ulong)arguments[2];
                pkg.UserID       = (uint)arguments[3];;
                pkg.TeamProperty = tbs((string)arguments[4]);;
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.SetTeamPropertyRsp] = (header) => {
                var rsp = (SetTeamPropertyRsp)SetTeamPropertyRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetTeamPropertyRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.NoticeTeamProperty] = (header) => {
                var rsp = (NoticeTeamProperty)NoticeTeamProperty.Descriptor.Parser.ParseFrom(header.data);
                Log.d("NoticeTeamProperty.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            //team user profile
            mE[(int)CmdId.SetTeamUserProfileReq] = (arguments) => {
                var pkg = new SetTeamUserProfileReq();
                pkg.GameID      = (uint)arguments[1];
                pkg.TeamID      = (ulong)arguments[2];
                pkg.UserID      = (uint)arguments[3];
                pkg.UserProfile = tbs((string)arguments[4]);
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.SetTeamUserProfileRsp] = (header) => {
                var rsp = (SetTeamUserProfileRsp)SetTeamUserProfileRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetTeamUserProfileRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.NoticeTeamUserProfile] = (header) => {
                var rsp = (NoticeTeamUserProfile)NoticeTeamUserProfile.Descriptor.Parser.ParseFrom(header.data);
                Log.d("NoticeTeamUserProfile.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };


            //timeout
            //team user profile
            mE[(int)CmdId.SetReconnectTimeoutReq] = (arguments) => {
                var pkg = new SetReconnectTimeoutReq();
                pkg.UserID  = (uint)arguments[1];
                pkg.Timeout = (int)arguments[2];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.SetReconnectTimeoutRsp] = (header) => {
                var rsp = (SetReconnectTimeoutRsp)SetReconnectTimeoutRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetReconnectTimeoutRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };
            mE[(int)CmdId.SetTeamReconnectTimeoutReq] = (arguments) => {
                var pkg = new SetTeamReconnectTimeoutReq();
                pkg.UserID  = (uint)arguments[1];
                pkg.Timeout = (int)arguments[2];
                return(fHe(pkg.ToByteArray(), (int)arguments[0]));
            };

            mD[(int)CmdId.SetTeamReconnectTimeoutRsp] = (header) => {
                var rsp = (SetTeamReconnectTimeoutRsp)SetTeamReconnectTimeoutRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("SetTeamReconnectTimeoutRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };


            //room - kick
            mE[(int)CmdId.KickPlayerReq] = (arguments) => {
                KickPlayer req = new KickPlayer();
                req.SrcUserID = (uint)arguments[2];
                req.RoomID    = (ulong)arguments[3];
                req.CpProto   = tbs((string)arguments[4]);
                req.UserID    = (uint)arguments[5];
                return(fHe(req.ToByteArray(), (int)arguments[0]));
            };
            mD[(int)CmdId.KickPlayerRsp] = (header) => {
                var rsp = (KickPlayerRsp)KickPlayerRsp.Descriptor.Parser.ParseFrom(header.data);
                Log.d("KickPlayerRsp.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };

            mD[(int)CmdId.KickPlayerNotify] = (header) => {
                var rsp = (KickPlayerNotify)KickPlayerNotify.Descriptor.Parser.ParseFrom(header.data);
                Log.d("KickPlayerNotify.Status:{0}", rsp);
                header.deserialization = rsp;
                return(header);
            };
        }
Beispiel #12
0
    public void onBtnCreate()
    {
        CreateRoom jr = getPage <CreateRoom>("PCreateRoom");

        jr.enter();
    }