Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ListeningClientHandler"/> class.
        /// </summary>
        /// <param name="messageIo">
        /// The <see cref="IMessageIO"/> interface.
        /// </param>
        /// <param name="messageNetworkReceiver">
        /// The <see cref="IMessageNetworkReceiver"/> interface.
        /// </param>
        /// <param name="client">
        /// The TCP client that is associated with this handler.
        /// </param>
        /// <param name="messageHandlers">
        /// The message handlers.
        /// </param>
        public ListeningClientHandler(
            IMessageIO messageIo,
            IMessageNetworkReceiver messageNetworkReceiver,
            TcpClient client,
            IEnumerable <IMessageHandler> messageHandlers)
        {
            this.m_MessageIo = messageIo;
            this.m_MessageNetworkReceiver = messageNetworkReceiver;
            this.m_Client        = client;
            this.m_ReceiveThread = new Thread(this.Run)
            {
                Name = "Receive Thread for " + client.Client.RemoteEndPoint
            };

            this.m_HandlerMappings = messageHandlers.ToDictionary(k => k.GetMessageType(), v => v);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ActiveClientHandler"/> class.
        /// </summary>
        /// <param name="messageIo">
        /// The <see cref="IMessageIO"/> interface.
        /// </param>
        /// <param name="messageNetworkReceiver">
        /// The <see cref="IMessageNetworkReceiver"/> interface.
        /// </param>
        /// <param name="address">
        /// The address that this client handler should connect to.
        /// </param>
        /// <param name="port">
        /// The port that this client handler should connect to.
        /// </param>
        /// <param name="messageHandlers">
        /// The message handlers.
        /// </param>
        public ActiveClientHandler(
            IMessageIO messageIo,
            IMessageNetworkReceiver messageNetworkReceiver,
            IPAddress address,
            int port,
            IEnumerable <IMessageHandler> messageHandlers)
        {
            this.m_MessageIo = messageIo;
            this.m_MessageNetworkReceiver = messageNetworkReceiver;
            this.m_Client = new TcpClient();
            this.m_Client.Connect(new IPEndPoint(address, port));
            this.m_ReceiveThread = new Thread(this.Run)
            {
                Name = "Active Client Thread for " + this.m_Client.Client.RemoteEndPoint
            };

            this.m_HandlerMappings = messageHandlers.ToDictionary(k => k.GetMessageType(), v => v);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ListeningClientHandler"/> class.
        /// </summary>
        /// <param name="messageIo">
        /// The <see cref="IMessageIO"/> interface.
        /// </param>
        /// <param name="messageNetworkReceiver">
        /// The <see cref="IMessageNetworkReceiver"/> interface.
        /// </param>
        /// <param name="client">
        /// The TCP client that is associated with this handler.
        /// </param>
        /// <param name="messageHandlers">
        /// The message handlers.
        /// </param>
        public ListeningClientHandler(
            IMessageIO messageIo,
            IMessageNetworkReceiver messageNetworkReceiver,
            TcpClient client, 
            IEnumerable<IMessageHandler> messageHandlers)
        {
            this.m_MessageIo = messageIo;
            this.m_MessageNetworkReceiver = messageNetworkReceiver;
            this.m_Client = client;
            this.m_ReceiveThread = new Thread(this.Run) { Name = "Receive Thread for " + client.Client.RemoteEndPoint };

            this.m_HandlerMappings = messageHandlers.ToDictionary(k => k.GetMessageType(), v => v);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ActiveClientHandler"/> class.
        /// </summary>
        /// <param name="messageIo">
        /// The <see cref="IMessageIO"/> interface.
        /// </param>
        /// <param name="messageNetworkReceiver">
        /// The <see cref="IMessageNetworkReceiver"/> interface.
        /// </param>
        /// <param name="address">
        /// The address that this client handler should connect to.
        /// </param>
        /// <param name="port">
        /// The port that this client handler should connect to.
        /// </param>
        /// <param name="messageHandlers">
        /// The message handlers.
        /// </param>
        public ActiveClientHandler(
            IMessageIO messageIo,
            IMessageNetworkReceiver messageNetworkReceiver,
            IPAddress address, 
            int port, 
            IEnumerable<IMessageHandler> messageHandlers)
        {
            this.m_MessageIo = messageIo;
            this.m_MessageNetworkReceiver = messageNetworkReceiver;
            this.m_Client = new TcpClient();
            this.m_Client.Connect(new IPEndPoint(address, port));
            this.m_ReceiveThread = new Thread(this.Run)
            {
                Name = "Active Client Thread for " + this.m_Client.Client.RemoteEndPoint
            };

            this.m_HandlerMappings = messageHandlers.ToDictionary(k => k.GetMessageType(), v => v);
        }