Beispiel #1
0
        /// <summary>
        /// Creates the instance for a new TCP server client.
        /// </summary>
        /// <param name="Server">Role server that the client connected to.</param>
        /// <param name="TcpClient">TCP client class that holds the connection and allows communication with the client.</param>
        /// <param name="UseTls">true if the client is connected to the TLS port, false otherwise.</param>
        /// <param name="Role">Role of the server the client connected to.</param>
        public IncomingClient(ProfileServer Server, TcpClient TcpClient, bool UseTls, ServerRole Role) :
            base(TcpClient, UseTls, 0, Server.Keys)
        {
            log = NLog.LogManager.GetLogger(string.Format("Test.ProfileServer.{0}.IncomingClient", Server.Name));
            log.Trace("(UseTls:{0})", UseTls);

            serverRole       = Role;
            server           = Server;
            messageProcessor = new MessageProcessor(server);

            ConversationStatus = ClientConversationStatus.NoConversation;

            log.Trace("(-)");
        }
Beispiel #2
0
        /// <summary>
        /// Creates the instance for a new TCP server client.
        /// </summary>
        /// <param name="Server">Role server that the client connected to.</param>
        /// <param name="TcpClient">TCP client class that holds the connection and allows communication with the client.</param>
        /// <param name="Id">Unique identifier of the client's connection.</param>
        /// <param name="UseTls">true if the client is connected to the TLS port, false otherwise.</param>
        /// <param name="KeepAliveIntervalMs">Number of seconds for the connection to this client to be without any message until the proximity server can close it for inactivity.</param>
        /// <param name="LogPrefix">Prefix for log entries created by the client.</param>
        public IncomingClient(TcpRoleServer <IncomingClient> Server, TcpClient TcpClient, ulong Id, bool UseTls, int KeepAliveIntervalMs, string LogPrefix) :
            base(TcpClient, new ProxMessageProcessor(Server, LogPrefix), Id, UseTls, KeepAliveIntervalMs, Server.IdBase, Server.ShutdownSignaling, LogPrefix)
        {
            this.Id = Id;
            log     = new Logger("ProximityServer.Network.IncomingClient", LogPrefix);

            log.Trace("(UseTls:{0},KeepAliveIntervalMs:{1})", UseTls, KeepAliveIntervalMs);

            messageBuilder = new ProxMessageBuilder(Server.IdBase, new List <SemVer>()
            {
                SemVer.V100
            }, Config.Configuration.Keys);
            this.KeepAliveIntervalMs = KeepAliveIntervalMs;
            NextKeepAliveTime        = DateTime.UtcNow.AddMilliseconds(this.KeepAliveIntervalMs);

            ConversationStatus = ClientConversationStatus.NoConversation;

            log.Trace("(-)");
        }
Beispiel #3
0
        /// <summary>
        /// Creates the encapsulation for a new TCP server client.
        /// </summary>
        /// <param name="Server">Role server that the client connected to.</param>
        /// <param name="TcpClient">TCP client class that holds the connection and allows communication with the client.</param>
        /// <param name="Id">Unique identifier of the client's connection.</param>
        /// <param name="UseTls">true if the client is connected to the TLS port, false otherwise.</param>
        /// <param name="KeepAliveIntervalSeconds">Number of seconds for the connection to this client to be without any message until the node can close it for inactivity.</param>
        public Client(TcpRoleServer Server, TcpClient TcpClient, ulong Id, bool UseTls, int KeepAliveIntervalSeconds)
        {
            this.TcpClient = TcpClient;
            this.Id        = Id;
            RemoteEndPoint = this.TcpClient.Client.RemoteEndPoint;

            server = Server;
            string logPrefix = string.Format("[{0}<=>{1}|0x{2:X16}] ", server.EndPoint, RemoteEndPoint, Id);
            string logName   = "HomeNet.Network.Client";

            this.log = new PrefixLogger(logName, logPrefix);

            log.Trace("(UseTls:{0},KeepAliveIntervalSeconds:{1})", UseTls, KeepAliveIntervalSeconds);

            messageProcessor = new MessageProcessor(server, logPrefix);

            this.KeepAliveIntervalSeconds = KeepAliveIntervalSeconds;
            NextKeepAliveTime             = DateTime.UtcNow.AddSeconds(this.KeepAliveIntervalSeconds);

            this.TcpClient.LingerState = new LingerOption(true, 0);
            this.TcpClient.NoDelay     = true;

            this.UseTls = UseTls;
            Stream      = this.TcpClient.GetStream();
            if (this.UseTls)
            {
                Stream = new SslStream(Stream, false, PeerCertificateValidationCallback);
            }

            MessageBuilder = new MessageBuilder(server.IdBase, new List <byte[]>()
            {
                new byte[] { 1, 0, 0 }
            }, Base.Configuration.Keys);
            ConversationStatus   = ClientConversationStatus.NoConversation;
            IsOurCheckedInClient = false;

            ApplicationServices = new ApplicationServices(logPrefix);

            log.Trace("(-)");
        }
Beispiel #4
0
        /// <summary>
        /// Creates the instance for a new TCP server client.
        /// </summary>
        /// <param name="Server">Role server that the client connected to.</param>
        /// <param name="TcpClient">TCP client class that holds the connection and allows communication with the client.</param>
        /// <param name="Id">Unique identifier of the client's connection.</param>
        /// <param name="UseTls">true if the client is connected to the TLS port, false otherwise.</param>
        /// <param name="KeepAliveIntervalSeconds">Number of seconds for the connection to this client to be without any message until the profile server can close it for inactivity.</param>
        public IncomingClient(TcpRoleServer Server, TcpClient TcpClient, ulong Id, bool UseTls, int KeepAliveIntervalSeconds) :
            base(TcpClient, UseTls, Server.IdBase)
        {
            this.Id = Id;
            server  = Server;
            string logPrefix = string.Format("[{0}<=>{1}|{2}] ", server.EndPoint, RemoteEndPoint, Id.ToHex());
            string logName   = "ProfileServer.Network.IncomingClient";

            log = new PrefixLogger(logName, logPrefix);

            log.Trace("(UseTls:{0},KeepAliveIntervalSeconds:{1})", UseTls, KeepAliveIntervalSeconds);

            messageProcessor = new MessageProcessor(server, logPrefix);

            this.KeepAliveIntervalSeconds = KeepAliveIntervalSeconds;
            NextKeepAliveTime             = DateTime.UtcNow.AddSeconds(this.KeepAliveIntervalSeconds);

            ConversationStatus   = ClientConversationStatus.NoConversation;
            IsOurCheckedInClient = false;

            ApplicationServices = new ApplicationServices(logPrefix);

            log.Trace("(-)");
        }