/// <summary> /// Constructs a new (incoming) message collector packet. /// /// Use this class to receive data from a client. /// This is an incoming message that will remain in the servers thread pool /// as a job for the thread pool workers. /// </summary> /// <param name="client">The packet's TCPClientConnection.</param> /// <param name="data">The string received.</param> /// <param name="previousPacket">The previous message collector packet of the TCPClientConnection.</param> public MessageCollectorTCPClientConnectionPacket(TCPClientConnection client, string data, MessageCollectorTCPClientConnectionPacket previousPacket) { fClient = client; fData = data; fPreviousPacket = previousPacket; ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData)); }
public void Dispose() { try { fIncomingDataBuffer = null; fETXStr = null; fMyClient = null; } catch (Exception ex) { } }
/// <summary> /// Constructs a new incoming packet for an existing TCP client connection. /// /// Use this class to receive data from a client. /// This is an incoming message that will remain in the servers thread pool /// as a job for the thread pool workers. /// </summary> /// <param name="client">The client where this message belongs to.</param> /// <param name="data">DataFrame class.</param> /// <param name="previousPacket">The previous incoming message of the client.</param> public IncomingTCPClientConnectionPacket(TCPClientConnection client, DataFrame data, IncomingTCPClientConnectionPacket previousPacket) { try { fClient = client; fData = data; fPreviousPacket = previousPacket; } catch (Exception ex) { return; } ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData)); }
/// <summary> /// Constructs a new outgoing packet for an existing TCP client connection. /// /// Use this class to send data from the server to a connected client. /// This is an outgoing message that will remain in the servers thread pool /// as a job for the thread pool workers. /// </summary> /// <param name="client">The client 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 client.</param> public OutgoingTCPClientConnectionPacket(TCPClientConnection client, byte[] bytes, int offset, int length, OutgoingTCPClientConnectionPacket previousPacket) { try { fClient = client; fBytes = bytes; fOffset = offset; fLength = length; fPreviousPacket = previousPacket; ThreadPool.QueueUserWorkItem(new WaitCallback(SendData)); } catch (Exception ex) { throw new OutgoingPacketFailedException(this); } }
public ClientIsDisconnectedException(TCPClientConnection client) :base("Client is disconnected.") { fClient = client; }
/// <summary> /// A client disconnects from this server. /// </summary> /// <param name="client"></param> public virtual void OnClientDisconnect(TCPClientConnection client) { }
/// <summary> /// Server is receiving data from a client connection. /// </summary> /// <param name="sender">The client sends the data to this server.</param> /// <param name="data">The incoming DataFrame.</param> public virtual void OnDataReceive(TCPClientConnection sender, DataFrame data) { }
private void Initialize(TCPClientConnection myClient, string splitter) { fMyClient = myClient; fETXStr = splitter; fIncomingDataBuffer = new StringBuilder(); }
public TCPClientConnectionMessageCollector(TCPClientConnection myClient, string splitter) { Initialize(myClient, splitter); fETXLength = splitter.Length; }
public TCPClientConnectionMessageCollector(TCPClientConnection myClient, char splitter) { Initialize(myClient, splitter.ToString()); fETXLength = 1; }