コード例 #1
0
        void process_connect_packet()
        {
            mRecvQueue.Switch();

            if (!mRecvQueue.Empty())
            {
                var buf = mRecvQueue.Pop();

                UInt32 conv = 0;
                KCP.ikcp_decode32u(buf, 0, ref conv);

                if (conv <= 0)
                {
                    throw new Exception("inlvaid connect back packet");
                }

                init_kcp(conv);

                mInConnectStage = false;
                mConnectSucceed = true;

                if (m_socketSink != null)
                {
                    m_socketSink.OnConnect(m_nSocketID);
                }
            }
        }
コード例 #2
0
ファイル: TCPSocketClient.cs プロジェクト: mengtest/MyGame
        private void Connected(IAsyncResult iar)
        {
            try
            {
                lock (m_QueueToSend.SyncRoot)
                {
                    m_QueueToSend.Clear();
                }

                m_Connection.EndConnect(iar);

                m_ThreadReceive = new Thread(new ThreadStart(ThreadReceive));
                m_ThreadSend    = new Thread(new ThreadStart(ThreadSend));



                m_bRunReceive = true;
                m_bRunSend    = true;

                m_ThreadReceive.Start();
                m_ThreadSend.Start();

                if (m_socketSink != null)
                {
                    m_socketSink.OnConnect(m_nSocketID);
                    //ConnectionCreated(this, new EventArgs());
                }
            }
            catch (SocketException)
            {
                if (m_socketSink != null)
                {
                    m_socketSink.OnConnectError(m_nSocketID, SOCKET_ERROR.SOCKET_ERROR_CONNECT_FAIL);
                }
            }
        }