Exemplo n.º 1
0
        private void m_SocketSendEventHandle(COMPLETE_OR_FAILED isComplete, string message)
        {
            DebugQy.LogTag("【LAM】m_SocketSendEventHandle", "SND CALL BACK:" + message);
            switch (isComplete)
            {
            case COMPLETE_OR_FAILED.DEFAULT:
                DebugQy.LogError("【LAM】m_SocketSendEventHandle" + "---SND CALL BACK:" + message);
                break;

            case COMPLETE_OR_FAILED.COMPLETE:
                //socket数据处理器直接处理数据
                break;

            case COMPLETE_OR_FAILED.FAILED:
                //发送失败逻辑处理
                m_LinkFailedEventTrigger((int)LINK_STATUS_CODE.SOCKET_SND_F);
                break;
            }
        }
Exemplo n.º 2
0
        private void m_SocketConnectedEventHandle(COMPLETE_OR_FAILED isComplete, string message)
        {
            DebugQy.LogTag("【LAM】m_SocketConnectedEventHandle", "---CON CALL BACK:" + message);
            switch (isComplete)
            {
            case COMPLETE_OR_FAILED.DEFAULT:
                DebugQy.LogError("【LAM】m_SocketConnectedEventHandle" + "---CON CALL BACK:" + message);
                break;

            case COMPLETE_OR_FAILED.COMPLETE:
                m_SocketClientController.ReceiveMessage();
                m_PushRoomVerification();
                break;

            case COMPLETE_OR_FAILED.FAILED:
                m_LinkFailedEventTrigger((int)LINK_STATUS_CODE.SOCKET_CON_F);
                break;
            }
        }
Exemplo n.º 3
0
        public SocketClientController(CLIENT_SOCKET_TYPE socketType, SOCKET_DATA_PROTOCOL protocolType)
        {
            //链接选择:未来改枚举
            switch (socketType)
            {
            case CLIENT_SOCKET_TYPE.TCP:
                m_clientSocket = new ClientSocket();
                break;

            case CLIENT_SOCKET_TYPE.UDP:
                break;

            default:
                break;
            }
            if (m_clientSocket == null)
            {
                DebugQy.LogError("m_clientSocket is null.");
            }
            //链接事件
            m_clientSocket.AnsyncConnectTo_Complete_Event += m_StartConnectedCompleteCallBack;
            m_clientSocket.AnsyncConnectTo_Failed_Event   += m_StartConnectedFailedCallBack;
            //协议注册:未来改枚举
            switch (protocolType)
            {
            case SOCKET_DATA_PROTOCOL.HEAD_BODY:
                m_transProtocol = new HeadBodyTcpProtocol();
                break;

            default:
                break;
            }
            m_transProtocol.SetTargetSocket(m_clientSocket);
            //协议事件
            m_transProtocol.SendMsgCompleteEvent += m_ProtocolSendCompleteCallback;
            m_transProtocol.SendMsgFailedEvent   += m_ProtocolSendFailedCallback;
            m_transProtocol.RecMsgCompleteEvent  += m_ProtocolRecvCompleteCallback;
            m_transProtocol.RecMsgFailedEvent    += m_ProtocolRecvFailedCallback;
        }
Exemplo n.º 4
0
        public WebEasyHttpQy(WEB_REQUEST_TYPE webNetType       = WEB_REQUEST_TYPE.HTTP,
                             WEB_DATA_PROTOCOL webDataProtocol = WEB_DATA_PROTOCOL.ORIGINAL)
        {
            switch (webNetType)
            {
            case WEB_REQUEST_TYPE.HTTP:
                m_WebRequest = new HttpWebRequestQy();
                break;

            default:
                DebugQy.LogError("'WEB_REQUEST_TYPE' can not clear. ");
                break;
            }
            switch (webDataProtocol)
            {
            case WEB_DATA_PROTOCOL.ORIGINAL:
                m_protocol = new WebKeepOrigDataProtocol();
                break;

            default:
                DebugQy.LogError("'WEB_DATA_PROTOCOL' can not clear. ");
                break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 事件选择器
        /// </summary>
        /// <param name="sender">私有变量m_SocketClientController</param>
        /// <param name="args">应用层参数</param>
        private void m_SocketEventFirCallBack(object sender, SocketClieCtrlEventArgs args)
        {
            switch (args.EventType)
            {
            case EVENT_TYPE.DEFAULT:
                DebugQy.LogError("【LAM】m_SocketSendEventHandle" + "EVENT HANDLE:");
                break;

            case EVENT_TYPE.CONNECT:
                m_SocketConnectedEventHandle(args.IsComplete, args.Message);
                break;

            case EVENT_TYPE.SEND:
                m_SocketSendEventHandle(args.IsComplete, args.Message);
                break;

            case EVENT_TYPE.RECEIVE:
                m_SocketReceiveEventHandle(args.IsComplete, args.Message);
                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
        private void m_SocketReceiveEventHandle(COMPLETE_OR_FAILED isComplete, string message)
        {
            DebugQy.LogTag("【LAM】m_SocketReceiveEventHandle", "REC CALL BACK:" + message);
            switch (isComplete)
            {
            case COMPLETE_OR_FAILED.DEFAULT:
                DebugQy.LogError("【LAM】m_SocketReceiveEventHandle" + "---REC CALL BACK:" + message);
                break;

            case COMPLETE_OR_FAILED.COMPLETE:
                ClearDataFormat _clearData;
                bool            _isSucc = m_datahandle.SocketStrDataHandle(message, out _clearData);
                //if (_clearData.Type != REV_MSG_TYPE.HEART_BEAT)
                //{
                //    DebugQy.LeoLog("<color=red>>>>>>>>:" + message + "</color>");
                //}
                if (_isSucc)
                {
                    switch (_clearData.Type)
                    {
                    case REV_MSG_TYPE.DEFAULT:
                        DebugQy.LogError("【LAM】case :0" + "---REC CALL BACK:" + message + "\n"
                                         + "type is not clear.");
                        break;

                    case REV_MSG_TYPE.HEART_BEAT:                              //20000 ---- 收到心跳信息
                        DebugQy.Log("【LAM】case :20000" + "HeatBeat:");
                        m_HeartBeatReturn(_clearData.Time);
                        return;

                    case REV_MSG_TYPE.ROOM_VERIFICATION_T:                      //21100 ---- 收到房间验证 正确
                        DebugQy.LogTag("【LAM】case :21100", "Room verification right.");
                        string codeStr = WEB_BASE_URL + "deviceId=" + m_deviceId + "&gameId=" + m_gameId + "&socketType=1";
                        m_isConnected = true;
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_ROOM_VERIFY_T, codeStr);
                        break;

                    case REV_MSG_TYPE.ROOM_VERIFICATION_F:                      //21101 ---- 收到房间验证 错误
                        DebugQy.LogTag("【LAM】case :21101", "Room verification wrong.");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_ROOM_VERIFY_F, "Verification failed.");
                        break;

                    case REV_MSG_TYPE.AWARD_LIST_T:                             //21200 ---- 收到 奖励申请 正确
                        DebugQy.LogTag("【LAM】case :21200", "奖励申请 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_AWARD_LIST_T, _clearData.Msg);
                        break;

                    case REV_MSG_TYPE.AWARD_LIST_F:                             //21201 ---- 收到 奖励申请 错误
                        DebugQy.LogTag("【LAM】case :21201", "奖励申请 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_AWARD_LIST_F, "Request award list failed.");
                        break;

                    case REV_MSG_TYPE.ROOM_STATUS_T:                            //22000 ---- 房间状态推送 正确
                        DebugQy.LogTag("【LAM】case :22000", "房间状态 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_ROOM_STATUS_T, _clearData.Msg);
                        break;

                    case REV_MSG_TYPE.ROOM_STATUS_F:                            //22001 ---- 房间状态推送 错误
                        DebugQy.LogTag("【LAM】case :22001", "房间状态 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_ROOM_STATUS_F, "Push room status failed.");
                        break;

                    case REV_MSG_TYPE.SUMMARIZE_T:                              //22100 ---- 收到 排行榜 正确
                        DebugQy.LogTag("【LAM】case :22100", "汇总数据 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_SUMMARIZE_T, _clearData.Msg);
                        break;

                    case REV_MSG_TYPE.SUMMARIZE_F:                              //22101 ---- 收到 排行榜 错误
                        DebugQy.LogTag("【LAM】case :22101", "汇总数据 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_SUMMARIZE_F, "Push rank list failed.");
                        break;

                    case REV_MSG_TYPE.PC_H5_T:                                  //40000 ---- 用户数据 正确
                        DebugQy.LogTag("【LAM】case :40000", "用户数据 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_CUSTOM_MSG_T, _clearData.Msg);
                        break;

                    case REV_MSG_TYPE.PC_H5_F:                                  //40001 ---- 用户数据 错误
                        DebugQy.LogTag("【LAM】case :40001", "用户数据 回复");
                        m_DataEventTrigger(DATA_STATUS_CODE.DATA_CUSTOM_MSG_F, "Recv user message failed.");
                        break;

                    case REV_MSG_TYPE.H5_LINK_BROKEN:                                //23000 ---- H5 断链 链接
                        DebugQy.LogTag("【LAM】case :23000", "用户断开链接信息");
                        m_DataEventTrigger(DATA_STATUS_CODE.LINK_USER_BROKEN, _clearData.Msg);
                        break;

                    default:
                        DebugQy.LogWarning("【LAM】Can not clear the type");
                        break;
                    }
                }
                else
                {
                    DebugQy.LogWarning("m_SocketSendEventHandle: Some format is wrong.check the message :" + message);
                }
                break;

            case COMPLETE_OR_FAILED.FAILED:
                UnityEngine.Debug.Log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:" + message);
                //接收失败逻辑处理
                m_LinkFailedEventTrigger((int)LINK_STATUS_CODE.SOCKET_REV_F);
                break;
            }
        }