Exemple #1
0
        /// <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);
        }
Exemple #2
0
        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}}";
        }
Exemple #3
0
 public InMemoryConnection(IHandshaker handshaker, ISerializer serializer, Client client) : base("inmemory", handshaker, serializer, client)
 {
 }
Exemple #4
0
 public TcpConnection(string remoteHost, ISerializer serializer, IHandshaker handshaker, Client client)
     : base(remoteHost, handshaker, serializer, client)
 {
     _client = new TcpClient();
 }
Exemple #5
0
 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);
 }