Exemple #1
0
    public void DoGameOperPlayerActionSyn(int action, params int[] card)
    {
        Debug.LogFormat("=>DoActionSyn action:{0},card1:{1},card2:{2}", ActionStr(action), card.Length > 0 ? GetCardStr(card[0]) : GetCardStr(-1), card.Length > 1 ? GetCardStr(card[1]) : GetCardStr(-1));
        RoomMgr.actionNotify.actions = 0;

        GameOperPlayerActionSyn content = new GameOperPlayerActionSyn();

        content.action = action;
        content.cardValue.AddRange(card);

        GameOperation request = new GameOperation()
        {
            operType = GameOperType.GameOperPlayerActionSyn
        };

        request.content = NetSerilizer.Serialize <GameOperPlayerActionSyn>(content);

        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.GameOperation
        };

        msg.data = NetSerilizer.Serialize <GameOperation>(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #2
0
    public void DoShareRequest()
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.ShareRequest
        };
        ShareRequest request = new ShareRequest()
        {
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #3
0
    public void DoReceiveMailAttachRequest(long msgId)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.ReceiveMailAttachRequest
        };
        ReadMailMsgRequest request = new ReadMailMsgRequest()
        {
            msgId = msgId
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #4
0
    public void DoKickPlayer(string code, int playerId)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.KickPlayerRequest
        };
        KickPlayerRequest request = new KickPlayerRequest()
        {
            code = code, playerId = playerId
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #5
0
    public void Auth(int userId, string token)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.AuthRequest
        };
        AuthRequest request = new AuthRequest()
        {
            userId = userId, token = token, version = GlobalConfig.GetVersion
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #6
0
    public void DoDismissVipRoom(string code)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.DismissVipRoomRequest
        };
        DismissVipRoomRequest request = new DismissVipRoomRequest()
        {
            code = code
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #7
0
    public void DoREADYL(int state, int phase) //TODO WXD send ready
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.ReadyRequest
        };
        ReadyRequest request = new ReadyRequest()
        {
            state = state, phase = phase
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #8
0
    public void DoModifyUserInfoRequest(string headImg, string nickName)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.ModifyUserInfoRequest
        };
        ModifyUserInfoRequest request = new ModifyUserInfoRequest()
        {
            headImg = headImg, nickName = nickName
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #9
0
    public void DoDissmissVoteSyn(bool ok)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.DissmissVoteSyn
        };
        DissmissVoteSyn request = new DissmissVoteSyn()
        {
            agree = ok
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #10
0
    public void DoEnterVipRoom(string psw)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.EnrollRequest
        };
        EnrollRequest request = new EnrollRequest()
        {
            roomCode = psw, gameId = "G_DQMJ"
        };

        msg.data = NetSerilizer.Serialize(request);

        SocketNetTools.SendMsg(msg);
    }
Exemple #11
0
    public void DoGameChatMsgRequest(byte[] content)
    {
        int        contentType = 3;//类型 1 文字 2图片 3语音
        PacketBase msg         = new PacketBase()
        {
            packetType = PacketType.GameChatMsgRequest
        };
        GameChatMsgRequest request = new GameChatMsgRequest()
        {
            contentType = contentType, content = content
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #12
0
    public void DoRegistVistor()
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.VistorRegisterRequest
        };
        int    deviceFlag             = GlobalConfig.GetPlatformId; //设备号 1:ios 2:android 3:winphon 4:other
        string deviceId               = GlobalConfig.DeviceId;
        VistorRegisterRequest request = new VistorRegisterRequest()
        {
            deviceFlag = deviceFlag, deviceId = deviceId
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #13
0
    public void LoginMsg(string username, string password, string ip, int type)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.LoginRequest
        };
        //设备号  1:ios 2:android 3:winphon 4:other
        int          deviceFlag = GlobalConfig.GetPlatformId;
        LoginRequest request    = new LoginRequest()
        {
            username = username, passward = password, ip = ip, type = type, version = GlobalConfig.GetVersion, deviceFlag = deviceFlag
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #14
0
    public void DoRegist(string account, string nickname, string password)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.RegisterRequest
        };
        int             deviceFlag = GlobalConfig.GetPlatformId; //设备号 1:ios 2:android 3:winphon 4:other
        string          deviceId   = GlobalConfig.DeviceId;
        RegisterRequest request    = new RegisterRequest()
        {
            account = account, nickname = nickname, password = password, deviceFlag = deviceFlag
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #15
0
    public void DoConfirmOrderRequest(string orderId, int platformId, int result, byte[] data)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.ConfirmOrderRequest
        };
        ConfirmOrderRequest request = new ConfirmOrderRequest();

        request.orderId    = orderId;
        request.platformId = platformId;
        request.result     = result;
        request.data       = data;

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #16
0
    public void DoGameChatMsgRequest(string content)
    {
        int contentType = 1;//类型 1 文字 2图片 3语音

        byte[] byteArray = System.Text.Encoding.Default.GetBytes(content);

        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.GameChatMsgRequest
        };
        GameChatMsgRequest request = new GameChatMsgRequest()
        {
            contentType = contentType, content = byteArray
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #17
0
    public void DoGenOrderRequest(int platformId, string productId, Action <GenOrderResponse> callback)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.GenOrderRequest
        };
        GenOrderRequest request = new GenOrderRequest()
        {
            platformId = platformId, productId = productId
        };

        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg, PacketType.GenOrderResponse, (data) =>
        {
            GenOrderResponse response = NetSerilizer.DeSerialize <GenOrderResponse>(data.data);
            callback(response);
        });
    }
Exemple #18
0
    public void DoRoomResult(long roomId, Action <RoomResultResponse> callback)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.RoomResultRequest
        };
        RoomResultRequest request = new RoomResultRequest()
        {
            roomId = roomId
        };

        msg.data = NetSerilizer.Serialize(request);

        SocketNetTools.SendMsg(msg, PacketType.RoomResultResponse, (data) =>
        {
            RoomResultResponse response = NetSerilizer.DeSerialize <RoomResultResponse>(data.data);
            callback(response);
        });
    }
Exemple #19
0
    public void SendMsg(PacketBase msg)
    {
        if (Connected)
        {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            string dataStr = Utils.ToStr(Utils.DeSerialize(msg));
            if (msg.packetType != PacketType.HEARTBEAT)
            {
                Debug.LogFormat("=>>:{0}; code:{1}; msg:{2};data:[{3}]", msg.packetType, msg.code, msg.msg, dataStr);
                //Debug.LogFormat("=>>:{0}; code:{1}; msg:{2};data:[{3}]", msg.packetType, msg.code, msg.msg, dataStr);
            }
#endif
            try
            {
                byte[] datas = NetSerilizer.Serialize(msg);

                byte[] result = NetEncode.Encode(datas);// Encoding.UTF8.GetBytes(msg);
                Debug.Log(result.Length);
                client.Send(result);
            }
            catch
            {
                Debug.Log("net close!");
                //               client.Shutdown(SocketShutdown.Both);
                //               client.Close();
                ////////////////20180423
                Game.SocketGame.SocketNetTools.StopClient();
                string gameserver = "daqingmj.youhao88.com:7000";
                Game.InitGameSocket(gameserver);
                ////////////////20180423
            }
        }
        else
        {
            Debug.LogWarning("SendMsg not Connected : " + msg.packetType);
            ////////////////20180423
            Game.SocketGame.SocketNetTools.StopClient();
            string gameserver = "daqingmj.youhao88.com:7000";
            Game.InitGameSocket(gameserver);
            ////////////////20180423            //Game.SocketGame.DoBackGameRequest();
        }
    }
Exemple #20
0
    public void DoCreateVipRoom(int vipRoomType, int quanNum, int wangfa, Action <VipRoomListSyn> callback)
    {
        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.CreateVipRoomRequest
        };
        CreateVipRoomRequest request = new CreateVipRoomRequest();

        request.vipRoomType = vipRoomType;
        request.quanNum     = quanNum;
        //request.vipRoomType = 0;
        request.wangfa = wangfa;

        msg.data = NetSerilizer.Serialize(request);

        SocketNetTools.SendMsg(msg, PacketType.VipRoomListSyn, (data) => {
            VipRoomListSyn result = NetSerilizer.DeSerialize <VipRoomListSyn>(data.data);
            callback(result);
        });
    }
Exemple #21
0
    public void DoENROLL(string matchType, List <int> cards = null)
    {
        Game.MJMgr.Clear();

        PacketBase msg = new PacketBase()
        {
            packetType = PacketType.EnrollRequest
        };
        EnrollRequest request = new EnrollRequest()
        {
            gameId = "G_DQMJ", matchId = matchType
        };

        if (null != cards)
        {
            request.cards.AddRange(cards);
        }
        msg.data = NetSerilizer.Serialize(request);
        SocketNetTools.SendMsg(msg);
    }
Exemple #22
0
    public void SendMsg(PacketBase msg)
    {
        if (Connected)
        {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            string dataStr = Utils.ToStr(Utils.DeSerialize(msg));
            if (msg.packetType != PacketType.HEARTBEAT)
            {
                Debug.LogFormat("=>>:{0}; code:{1}; msg:{2};data:[{3}]", msg.packetType, msg.code, msg.msg, dataStr);
                //Debug.LogFormat("=>>:{0}; code:{1}; msg:{2};data:[{3}]", msg.packetType, msg.code, msg.msg, dataStr);
            }
#endif

            byte[] datas = NetSerilizer.Serialize(msg);

            byte[] result = NetEncode.Encode(datas);// Encoding.UTF8.GetBytes(msg);
            Debug.Log(result.Length);
            client.Send(result);
        }
        else
        {
            Debug.LogWarning("SendMsg not Connected : " + msg.packetType);
        }
    }