Пример #1
0
    private void OnReciveOtherPlayerEnter(CmdMsg msg)
    {
        OtherPlayerEnter ot = ProtoMan.ProtobufDeserialize <OtherPlayerEnter>(msg.body);

        GameInfo.Instance.other.Add(ot);
        ModuleManager.Instance.Invoke("OtherEnterRoom", null);
    }
Пример #2
0
    private void OnRoomListReturn(CmdMsg msg)
    {
        RoomList res = ProtoMan.ProtobufDeserialize <RoomList>(msg.body);

        GameInfo.Instance.RoomListInfo = res.room_list;
        ModuleManager.Instance.Invoke("SyncRoomList", null);
    }
Пример #3
0
    private void OnReciveOtherPlayerReady(CmdMsg msg)
    {
        OtherPlayerReady ot = ProtoMan.ProtobufDeserialize <OtherPlayerReady>(msg.body);;

        object[] obj = new object[1];
        obj[0] = ot.seat_id;
        ModuleManager.Instance.Invoke("OtherPlayerReady", obj);
    }
Пример #4
0
    private void OnReciveMovResReturn(CmdMsg msg)
    {
        MovResReturn ms = ProtoMan.ProtobufDeserialize <MovResReturn>(msg.body);

        object[] obj = new object[1];
        obj[0] = ms;
        ModuleManager.Instance.Invoke("PlayChessMove", obj);
    }
Пример #5
0
    private void OnCreateRoomResReturn(CmdMsg msg)
    {
        CreateRoomRes res = ProtoMan.ProtobufDeserialize <CreateRoomRes>(msg.body);

        GameInfo.Instance.RoomId = res.room_id;
        GameInfo.Instance.SeatId = res.seat_id;
        SceneManager.LoadScene(1);
    }
Пример #6
0
    private void OnLoginResReturn(CmdMsg msg)
    {
        LoginRes res = ProtoMan.ProtobufDeserialize <LoginRes>(msg.body);

        if (res.status == 1)
        {
            ModuleManager.Instance.Invoke("OnLoginReturn", null);
        }
    }
    private void OnRecvClientCmd(byte[] buf, int len)
    {
        CmdMsg msg;

        ProtoMan.UnpackMsgCmd(buf, 2, len, out msg);


        if (msg != null)
        {
            lock (eventQueue)
            {
                eventQueue.Enqueue(msg);
            }
        }
    }
Пример #8
0
    private void OnReciveOtherPlayerExit(CmdMsg msg)
    {
        OtherPlayerExit ot = ProtoMan.ProtobufDeserialize <OtherPlayerExit>(msg.body);

        for (int i = 0; i < GameInfo.Instance.other.Count; i++)
        {
            if (GameInfo.Instance.other[i] != null)
            {
                if (GameInfo.Instance.other[i].seat_id == ot.seat_id)
                {
                    GameInfo.Instance.other[i] = null;
                }
            }
        }
        ModuleManager.Instance.Invoke("OtherEnterRoom", null);
    }
    void SendJsonCmd(int stype, int ctype, string jsonBody)
    {
        byte[] cmdData = ProtoMan.PackJsonCmd(stype, ctype, jsonBody);
        if (cmdData == null)
        {
            return;
        }
        byte[] tcpPkg = TcpPacker.Pack(cmdData);

        clientSocket.BeginSend(tcpPkg, 0, tcpPkg.Length, SocketFlags.None, new AsyncCallback((IAsyncResult ir) =>
        {
            try
            {
                Socket client = (Socket)ir.AsyncState;
            }
            catch
            {
            }
        }), clientSocket);
    }
    public void SendProtobufCmd(int stype, int ctype, ProtoBuf.IExtensible body)
    {
        byte[] cmdData = ProtoMan.PackProtobufCmd(stype, ctype, body);
        if (cmdData == null)
        {
            return;
        }
        byte[] tcpPkg = TcpPacker.Pack(cmdData);

        clientSocket.BeginSend(tcpPkg, 0, tcpPkg.Length, SocketFlags.None, new AsyncCallback((IAsyncResult ir) =>
        {
            try
            {
                Socket client = (Socket)ir.AsyncState;
            }
            catch
            {
                ModuleManager.Instance.Invoke("Log", "Failed to Send Cmd");
            }
        }), clientSocket);
    }