コード例 #1
0
        public WebSocketConnector(IPacketFormat packetFormat, IPacketHandlerManager packetHandlerManager) : base(packetFormat, packetHandlerManager)
        {
            mSocket              = null;
            mNetStream           = new NetStream(INetConnector.MAX_SOCKET_BUFFER_SIZE * 2);
            tempReadPacketLength = 0;
            tempReadPacketType   = 0;
            tempReadPacketData   = null;

            mSendThread = new AsyncThread(SendLogic);
            mSendThread.Start();
        }
コード例 #2
0
        public WebSocketConnector(IPacketFormat packetFormat, IPacketHandlerManager packetHandlerManager)
            : base(packetFormat, packetHandlerManager)
        {
            mSocket = null;
            mNetStream = new NetStream(INetConnector.MAX_SOCKET_BUFFER_SIZE * 2);
            tempReadPacketLength = 0;
            tempReadPacketType = 0;
            tempReadPacketData = null;

            mSendThread = new AsyncThread(SendLogic);
            mSendThread.Start();
        }
コード例 #3
0
ファイル: UDPConnector.cs プロジェクト: gaolijunGit/Rosetta
        public UDPConnector(IPacketFormat packetFormat, IPacketHandlerManager packetHandlerManager) : base(packetFormat, packetHandlerManager)
        {
            mSocket              = null;
            mRemoteEndPoint      = null;
            mNetStream           = new NetStream(INetConnector.MAX_SOCKET_BUFFER_SIZE * 2);
            tempReadPacketLength = 0;
            tempReadPacketType   = 0;
            tempReadPacketData   = null;

            mReadCompleteCallback = new AsyncCallback(ReadComplete);
            mSendCompleteCallback = new AsyncCallback(SendComplete);

            mSendThread = new AsyncThread(SendLogic);
            mSendThread.Start();
        }
コード例 #4
0
ファイル: TCPConnector.cs プロジェクト: gaolijunGit/Rosetta
        public override void Connect(string address, int port)
        {
            SetConnectStatus(ConnectionStatus.CONNECTING);
            base.Connect(address, port);
            mSocket = new TcpClient();
            AsyncThread connectThread = new AsyncThread((thread) => {
                try
                {
                    mSocket.Connect(mRemoteHost.GetAddress(), mRemoteHost.GetPort());
                    mSocket.GetStream().BeginRead(mNetStream.AsyncPipeIn, 0, INetConnector.MAX_SOCKET_BUFFER_SIZE, mReadCompleteCallback, this);
                    SetConnectStatus(ConnectionStatus.CONNECTED);
                }
                catch (Exception e)
                {
                    LoggerSystem.Instance.Error(e.Message);
                    SetConnectStatus(ConnectionStatus.ERROR);
                }

                CallbackConnected(IsConnected());
            });

            connectThread.Start();
        }
コード例 #5
0
ファイル: TCPConnector.cs プロジェクト: AlkaidFang/Rosetta
        public override void Connect(string address, int port)
        {
            SetConnectStatus(ConnectionStatus.CONNECTING);
            base.Connect(address, port);
            mSocket = new TcpClient();
            AsyncThread connectThread = new AsyncThread ((thread) => {

                try
                {
                    mSocket.Connect(mRemoteHost.GetAddress(), mRemoteHost.GetPort());
                    mSocket.GetStream().BeginRead(mNetStream.AsyncPipeIn, 0, INetConnector.MAX_SOCKET_BUFFER_SIZE, mReadCompleteCallback, this);
                    SetConnectStatus(ConnectionStatus.CONNECTED);
                }
                catch(Exception e)
                {
                    LoggerSystem.Instance.Error(e.Message);
                    SetConnectStatus(ConnectionStatus.ERROR);
                }

                CallbackConnected(IsConnected());
            });

            connectThread.Start ();
        }