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(); }
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(); }
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(); }
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 (); }