Пример #1
0
        private void m_ConnectEventFiring(FIRING_D_C_F firType, ISocketConEventArgs conArgs, string funcionTag)
        {
            switch (firType)
            {
            case FIRING_D_C_F.DEFAULT:

                break;

            case FIRING_D_C_F.FIR_COMPLETE:
                DebugQy.LogTag(funcionTag, firType.ToString(), "#59A7CEFF");
                if (AnsyncConnectTo_Complete_Event != null)
                {
                    ISocketConEventArgs _args = conArgs;
                    AnsyncConnectTo_Complete_Event(this, _args);
                }
                break;

            case FIRING_D_C_F.FIR_FAILED:
                DebugQy.LogTag(funcionTag, firType.ToString() + conArgs.ErrMessage, "#BB7979FF");
                if (AnsyncConnectTo_Failed_Event != null)
                {
                    ISocketConEventArgs _args = conArgs;
                    AnsyncConnectTo_Failed_Event(this, conArgs);
                }
                break;

            default:

                break;
            }
        }
Пример #2
0
        private void m_ConnectCallBack(IAsyncResult asyncResult)
        {
            FIRING_D_C_F        _firEventType = FIRING_D_C_F.DEFAULT;
            string              errorMessage  = string.Empty;
            SocketAnsynParam    _ansynParam   = asyncResult.AsyncState as SocketAnsynParam;
            ISocketConEventArgs _conEventArgs = _ansynParam.transEventArgs as ISocketConEventArgs;

            try
            {
                _ansynParam.workSocket.EndConnect(asyncResult);
                errorMessage  = "√√√ no mistake √√√";
                _firEventType = FIRING_D_C_F.FIR_COMPLETE;
            }
            catch (ArgumentNullException ee)
            {
                errorMessage = "×××  ArgumentNullException  ×××:"
                               + " asyncResult 为 null。"
                               + ee.Message;
                _firEventType = FIRING_D_C_F.FIR_FAILED;
            }
            catch (ArgumentException ee)
            {
                errorMessage = "×××  ArgumentException  ×××:"
                               + " BeginConnect 方法调用未返回 asyncResult。"
                               + ee.Message;
                _firEventType = FIRING_D_C_F.FIR_FAILED;
            }
            catch (SocketException ee)
            {
                errorMessage = "×××  SocketException  ×××:"
                               + " 试图访问套接字时发生错误。"
                               + ee.Message;
                _firEventType = FIRING_D_C_F.FIR_FAILED;
            }
            catch (ObjectDisposedException ee)
            {
                errorMessage = "×××  ObjectDisposedException  ×××:"
                               + "Socket 已关闭。"
                               + ee.Message;
                _firEventType = FIRING_D_C_F.FIR_FAILED;
            }
            catch (InvalidOperationException ee)
            {
                errorMessage = "×××  InvalidOperationException  ×××:"
                               + "先前曾为异步连接调用过 EndConnect。"
                               + ee.Message;
                _firEventType = FIRING_D_C_F.FIR_FAILED;
            }
            catch (Exception ee)
            {
                errorMessage = "×××  Unknown exception  ××× :"
                               + "Firing other unknown exception !!!!!!"
                               + ee.Message;
                _firEventType = FIRING_D_C_F.FIR_FAILED;
            }
            DebugQy.LogTag("<<<<<<< CON ENP IN CLIENT >>>>>>>", "*-*-*-*-*[ out ]*-*-*-*-*");
            _conEventArgs.SetErrMessage(errorMessage);
            m_ConnectEventFiring(_firEventType, _conEventArgs, "m_ConnectCallBack");
        }