コード例 #1
0
    //套接口消息.
    public static void Update()
    {
        //处理网络消息
        lock (ClientProxy.Packet)
        {
            MemoryStream ms = null;
            foreach (var each in ClientProxy.Packet)
            {
                switch (each.Key)
                {
                case (int)MeteorMsg.MsgType.GetRoomRsp:
                    ms = new MemoryStream(each.Value);
                    GetRoomRsp rspG = ProtoBuf.Serializer.Deserialize <GetRoomRsp>(ms);
                    OnGetRoomRsp(rspG);
                    break;

                case (int)MeteorMsg.MsgType.JoinRoomRsp:
                    ms = new MemoryStream(each.Value);
                    JoinRoomRsp rspJ = ProtoBuf.Serializer.Deserialize <JoinRoomRsp>(ms);
                    OnJoinRoomRsp(rspJ);
                    break;

                case (int)MeteorMsg.MsgType.OnJoinRoomRsp:
                    ms = new MemoryStream(each.Value);
                    OnEnterRoomRsp rspE = ProtoBuf.Serializer.Deserialize <OnEnterRoomRsp>(ms);
                    OnEnterRoomRsp_(rspE);
                    break;

                case (int)MeteorMsg.MsgType.CreateRoomRsp:
                    ms = new MemoryStream(each.Value);
                    CreateRoomRsp rspC = ProtoBuf.Serializer.Deserialize <CreateRoomRsp>(ms);
                    OnCreateRoomRsp(rspC);
                    break;

                case (int)MeteorMsg.MsgType.EnterLevelRsp:
                    ms = new MemoryStream(each.Value);
                    EnterLevelRsp rspER = ProtoBuf.Serializer.Deserialize <EnterLevelRsp>(ms);
                    EnterLevelRsp_(rspER);
                    break;

                case (int)MeteorMsg.MsgType.OnEnterLevelRsp:
                    ms = new MemoryStream(each.Value);
                    OnEnterLevelRsp rspOE = ProtoBuf.Serializer.Deserialize <OnEnterLevelRsp>(ms);
                    OnEnterLevelRsp_(rspOE);
                    break;

                case (int)MeteorMsg.MsgType.OnLeaveRoomRsp:
                    ms = new MemoryStream(each.Value);
                    OnLeaveRoomRsp rspL = ProtoBuf.Serializer.Deserialize <OnLeaveRoomRsp>(ms);
                    OnLevvaRoomRsp_(rspL);
                    break;

                case (int)MeteorMsg.MsgType.SyncInput:
                    ms = new MemoryStream(each.Value);
                    InputReq InputRsp = ProtoBuf.Serializer.Deserialize <InputReq>(ms);
                    OnSyncInputRsp(InputRsp);
                    break;

                case (int)MeteorMsg.MsgType.SyncKeyFrame:
                    ms = new MemoryStream(each.Value);
                    KeyFrame KeyFrameRsp = ProtoBuf.Serializer.Deserialize <KeyFrame>(ms);
                    OnSyncKeyFrame(KeyFrameRsp);
                    break;
                }
            }
            ClientProxy.Packet.Clear();
        }

        lock (messageQueue)
        {
            int length = messageQueue.Count;
            for (int i = 0; i < length; i++)
            {
                switch (messageQueue[i].Message)
                {
                case (short)LocalMsgType.Connect: OnConnect(messageQueue[i].Result); break;

                case (short)LocalMsgType.DisConnect: OnDisconnect(); break;

                case (short)LocalMsgType.SendFTPLogComplete: OnSendComplete(messageQueue[i].Result, messageQueue[i].Param); break;
                }
            }
            messageQueue.Clear();
        }
    }
コード例 #2
0
 static void OnLevvaRoomRsp_(OnLeaveRoomRsp rsp)
 {
     //rsp.playerId
 }