Example #1
0
 // Token: 0x06006AF8 RID: 27384 RVA: 0x001E0148 File Offset: 0x001DE348
 private void OnCompletedForConnect(object sender, SocketAsyncEventArgs eventArgs)
 {
     try
     {
         if (eventArgs.SocketError != SocketError.Success)
         {
             CCMSGConnectionFailure msg = new CCMSGConnectionFailure();
             this.WriteMsg2RecvCache(msg);
             this.State = ConnectionState.Closed;
         }
         else
         {
             this.State = ConnectionState.Established;
             CCMSGConnectionReady msg2 = new CCMSGConnectionReady();
             this.WriteMsg2RecvCache(msg2);
             this.m_receiveEventArg            = new SocketAsyncEventArgs();
             this.m_receiveEventArg.Completed += this.OnCompletedForReceive;
             this.m_receiveEventArg.SetBuffer(new byte[65536], 0, 65536);
             if (!this.m_socket.ReceiveAsync(this.m_receiveEventArg))
             {
                 this.OnCompletedForReceive(null, this.m_receiveEventArg);
             }
         }
     }
     catch
     {
     }
 }
        private void OnCompletedForConnectImpl(SocketAsyncEventArgs e)
        {
            try
            {
                if (e.SocketError == SocketError.Success)
                {
                    /// Change connection state to ready
                    State = ConnectionState.Established;

                    // as soon as the client is connected, post a receive to the connection
                    if (!ConnSocket.ReceiveAsync(m_receiveEventArg))
                    {
                        OnCompletedForReceiveImpl(m_receiveEventArg);
                    }

                    /// Make a connection ready notification
                    CCMSGConnectionReady ccReadyMsg = new CCMSGConnectionReady();
                    RecvQueue.Enqueue(new KeyValuePair <int, object>(ccReadyMsg.MessageId, ccReadyMsg));
                    return;
                }
                else
                {
                    goto FAIL_CONNECT;
                }
            }
            catch
            {
                goto FAIL_CONNECT;
            }

FAIL_CONNECT:
            CCMSGConnectionFailure ccFailMsg = new CCMSGConnectionFailure();

            lock (RecvQueue)
            {
                RecvQueue.Enqueue(new KeyValuePair <int, object>(ccFailMsg.MessageId, ccFailMsg));
            }
            State = ConnectionState.Closed;
        }