Beispiel #1
0
    byte[] PackageSendData(int cmd, byte[] data)
    {
        qp_server.qp_packet req = new qp_server.qp_packet();
        req.cmd        = cmd;
        req.serialized = data;

        byte[] pbBuf = CmdBase.ProtoBufSerialize(req);

        //外层包

        if (pbBuf == null)
        {
            return(null);
        }

        //             1.包长度
        int headSize  = sizeof(int);
        int headIndex = 0;

        byte[] buff = new byte[pbBuf.Length + headSize];

        byte[] lenBuf = BitConverter.GetBytes((int)IPAddress.HostToNetworkOrder((int)(pbBuf.Length)));
        lenBuf.CopyTo(buff, headIndex);
        headIndex += headSize;

        pbBuf.CopyTo(buff, headIndex);

        return(buff);
    }
Beispiel #2
0
    public void OnCompletePacket(qp_server.qp_packet packet)
    {
        switch ((qp_server.ws_cmd)packet.cmd)
        {
        case qp_server.ws_cmd.CMD_QP_LOGIN_RSP:
            OnLoginRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_login_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_CREATE_ROOM_RSP:
            OnCreateRoomRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_create_room_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_JOIN_ROOM_RSP:
            OnJoinRoomRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_join_room_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_PING_RSP:
            Log.Error("currentScene[HALL], ping_rsp");
            break;

        case qp_server.ws_cmd.CMD_QP_KICK:
            Log.Error("kick");
            OnKick(CmdBase.ProtoBufDeserialize <qp_server.qp_kick>(packet.serialized));
            break;

        default:
            Log.Error("currentScene[HALL], unknown cmd={0}", packet.cmd);
            break;
        }
    }
Beispiel #3
0
    public void OnCompletePacket(qp_server.qp_packet packet)
    {
        switch ((qp_server.ws_cmd)packet.cmd)
        {
        case qp_server.ws_cmd.CMD_QP_LOGIN_RSP:
            OnLoginRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_login_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_JOIN_ROOM_PUSH:
            OnJoinRoomPush(CmdBase.ProtoBufDeserialize <qp_server.qp_join_room_push>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_SITDOWN_RSP:
            OnSitdownRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_sitdown_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_SITDOWN_PUSH:
            OnSitdownPush(CmdBase.ProtoBufDeserialize <qp_server.qp_sitdown_push>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_STANDUP_RSP:
            OnStandupRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_standup_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_STANDUP_PUSH:
            OnStandupPush(CmdBase.ProtoBufDeserialize <qp_server.qp_standup_push>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_EXIT_ROOM_RSP:
            OnExitRoomRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_exit_room_rsp>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_EXIT_ROOM_PUSH:
            OnExitRoomPush(CmdBase.ProtoBufDeserialize <qp_server.qp_exit_room_push>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_ROOM_DISSMISS:
            OnRoomDissmiss(CmdBase.ProtoBufDeserialize <qp_server.qp_room_dissmiss>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_ROOM_KICK:
            OnRoomKick(CmdBase.ProtoBufDeserialize <qp_server.qp_room_kick>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_KICK:
            OnKick(CmdBase.ProtoBufDeserialize <qp_server.qp_kick>(packet.serialized));
            break;

        case qp_server.ws_cmd.CMD_QP_PING_RSP:
            Log.Error("currentScene[ROOM], ping_rsp");
            break;

        default:
            Log.Error("currentScene[ROOM], unknown cmd={0}", packet.cmd);
            break;
        }
    }
Beispiel #4
0
    void OnCompletePacket(object[] args)
    {
        IncomingPacket packet = args[0] as IncomingPacket;

        if (packet == null)
        {
            return;
        }

        qp_server.qp_packet qpPacket = CmdBase.ProtoBufDeserialize <qp_server.qp_packet>(packet.recvBuff);
        currentScene.OnCompletePacket(qpPacket);
    }
Beispiel #5
0
    public void OnCompletePacket(qp_server.qp_packet packet)
    {
        switch ((qp_server.ws_cmd)packet.cmd)
        {
        case qp_server.ws_cmd.CMD_QP_LOGIN_RSP:
            OnLoginRsp(CmdBase.ProtoBufDeserialize <qp_server.qp_login_rsp>(packet.serialized));
            break;

        default:
            Log.Error("currentScene[LOGIN], unknown cmd={0}", packet.cmd);
            break;
        }
    }