/// <summary> /// Constructor for TCPServerConnector /// </summary> /// <param name="port">A UInt16 with the port.</param> public TCPServerConnector(UInt16 port, AbstractMessageParser parser) { listener = new TcpListener(IPAddress.Any, port); this.port = port; this.parser = parser; this.isAccepting = false; }
/// <summary> /// Initializes the TCPConnection with the given TcpClient. /// </summary> /// <param name="client">The TcpClient to the server.</param> public TCPConnection(TcpClient client, AbstractMessageParser parser) { this.client = client; this.stream = client.GetStream(); this.writer = new StreamWriter(stream); this.reader = new StreamReader(stream); this.parser = parser; this.localEndPoint = client.Client.LocalEndPoint; this.remoteEndPoint = client.Client.RemoteEndPoint; }
/// <summary> /// Initializes the TCPConnection to the given hostname / port. /// </summary> /// <param name="hostname">A String with the hostname of the server</param> /// <param name="port">A UInt16 with the port of the server.</param> public TCPConnection(String hostname, UInt16 port, AbstractMessageParser parser) { this.client = new TcpClient(hostname, port); this.stream = client.GetStream(); this.writer = new StreamWriter(stream); this.reader = new StreamReader(stream); this.parser = parser; this.localEndPoint = client.Client.LocalEndPoint; this.remoteEndPoint = client.Client.RemoteEndPoint; }
/// <summary> /// Constructor for ClientConnectionListener. /// </summary> /// <param name="port">This is a UInt16 representing the port to listen to.</param> /// <param name="MessageReceived">This is a delegate representing the callback to be fired when a /// ClientConnection connected through this listener is sends a message</param> /// <param name="ConnectionFailed">This is a delegate representing the callback to be fired when a /// ClientConnection connected through this listener fails</param> /// <param name="InitialConnectionFailure">This is a delegate representing the callback to fired /// when an client tried to connect, but for whatever reason, failed in doing so</param> /// <param name="InitialConnectionSuccess">This is a delegate representing the callback to be fired /// when a client connected through this listener</param> /// <param name="MessageFailed">This is a delegate representing the callback to be fired when a /// ClientConnection connected through this listener sends a corrupted message</param> public ClientConnectionListener(UInt16 port, AbstractMessageParser parser) { this.listener = new TCPServerConnector(port, parser); }