/// <summary> /// Creates a <see cref="TcpConnection"/> from and already open <see cref="TcpClient"/> /// </summary> /// <param name="client"></param> /// <param name="serializer"></param> /// <param name="handshaker"></param> public TcpConnection(TcpClient client, ISerializer serializer, IHandshaker handshaker, Server server) : base(client.Client.RemoteEndPoint.ToString(), handshaker, serializer, server) { _client = client ?? throw new ArgumentNullException(nameof(client)); _clientStream = _client.GetStream() ?? throw new ArgumentNullException(nameof(_client) + "." + nameof(_client.GetStream)); IsListenerConnection = true; TransitionState(ConnectionState.Connecting); }
protected ConnectionBase(string remoteAddress, IHandshaker handshaker, ISerializer serializer, Client client) { if (string.IsNullOrWhiteSpace(remoteAddress)) { throw new ArgumentNullException(remoteAddress); } Handshaker = handshaker ?? throw new ArgumentNullException(nameof(handshaker)); Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); Client = client ?? throw new ArgumentNullException(nameof(client)); RemoteAddress = remoteAddress; _toString = $"{{0}}:{ConnectionId}:{RemoteAddress}:{{1}}"; }
public InMemoryConnection(IHandshaker handshaker, ISerializer serializer, Client client) : base("inmemory", handshaker, serializer, client) { }
public TcpConnection(string remoteHost, ISerializer serializer, IHandshaker handshaker, Client client) : base(remoteHost, handshaker, serializer, client) { _client = new TcpClient(); }
public TcpConnectionCreator(IHandshaker handshaker) { Handshaker = handshaker ?? throw new ArgumentNullException(nameof(handshaker)); }
public TcpListener(IPEndPoint endpoint, IHandshaker handshaker) { EndPoint = endpoint; _handshaker = handshaker ?? throw new ArgumentNullException(nameof(handshaker)); _listener = new System.Net.Sockets.TcpListener(endpoint); }