public MessageCollectorTCPClientPacket(TCPConnector connector, String data, MessageCollectorTCPClientPacket previousPacket) { fConnector = connector; fData = data; fPreviousPacket = previousPacket; ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData)); }
/// <summary> /// Constructs a new incoming packet received by a TCP connector. /// Use this class to receive data from a server. /// This is an incoming message that will remain in the client's thread pool /// as a job for the thread pool workers. /// </summary> /// <param name="connector">The TCP Connector where this message belongs to.</param> /// <param name="data">DataFrame class.</param> /// <param name="previousPacket">The previous incoming message of the TCP Connector.</param> public IncomingTCPClientPacket(TCPConnector connector, DataFrame data, IncomingTCPClientPacket previousPacket) { fConnector = connector; fData = data; fPreviousPacket = previousPacket; ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData)); }
/// <summary> /// Constructs a new outgoing packet for an existing TCP Connector. /// Use this class to send data from the TCP Connector to a server. /// This is an outgoing message that will remain in the servers thread pool /// as a job for the thread pool workers. /// </summary> /// <param name="connector">TCPConnector where this message belongs to.</param> /// <param name="bytes">The byte array to be sent.</param> /// <param name="offset">The position in the data buffer at witch to begin sending.</param> /// <param name="length">The number of the bytes to be send.</param> /// <param name="previousPacket">The previous outgoing packet of the TCPConnector.</param> public OutgoingTCPClientPacket(TCPConnector connector, byte[] bytes, int offset, int length, OutgoingTCPClientPacket previousPacket) { fConnector = connector; fBytes = bytes; fOffset = offset; fLength = length; fPreviousPacket = previousPacket; ThreadPool.QueueUserWorkItem(new WaitCallback(SendData)); }
public void Dispose() { try { fIncomingDataBuffer = null; fETXStr = null; fMyConnector = null; } catch (Exception ex) { } }
public ConnectorCannotSendPacketException(TCPConnector connector, OutgoingTCPClientPacket packet) : base("Connector is disconnected") { fConnector = connector; fPacket = packet; }
public TCPClientMessageCollector(TCPConnector connector, char ETX) { Initialize(connector, ETX.ToString()); fETXLength = 1; }
/// <summary> /// Add a new connector with message collector. /// </summary> /// <param name="name">The connector's name.</param> /// <param name="serverIP">The remote host's (server) IP address.</param> /// <param name="serverPort">The remote host's (server) port.</param> /// <param name="readBufferSize">The read buffer size for this connection in bytes.</param> /// <param name="splitter">The the messages splitter string.</param> /// <returns>The connector.</returns> public TCPConnector AddConnector(string name, IPAddress serverIP, int serverPort, int readBufferSize, string splitter) { TCPConnector connector = new TCPConnector(this, name, serverIP, serverPort, readBufferSize, splitter); fConnectors.Add(connector); return connector; }
/// <summary> /// A connector of this client has been disconnected. /// </summary> /// <param name="connector"></param> public virtual void OnDisconnect(TCPConnector connector) { // Console.WriteLine("Connector " + connector.Name + " disconnected!"); }
/// <summary> /// A connector of this client receives data. /// </summary> /// <param name="connector">The client's connector.</param> /// <param name="data">The received data.</param> public virtual void OnDataReceive(TCPConnector connector, DataFrame data) { Console.WriteLine(Encoding.Default.GetString(data.Bytes)); }
private void Initialize(TCPConnector connector, string splitter) { fMyConnector = connector; fETXStr = splitter; fIncomingDataBuffer = new StringBuilder(); }
public TCPClientMessageCollector(TCPConnector connector, string splitter) { Initialize(connector, splitter); fETXLength = splitter.Length; }
public ConnectorDisconnectedException(TCPConnector connector) : base("Connector is disconnected") { fConnector = connector; }
public void AInitialize() { _tcpConnection = new TCPConnector(); }