private ProxyObserver CreateRemoteObserver(IPEndPoint remoteEndpoint)
        {
            TransportClient <IRemoteEvent <T> > client =
                new TransportClient <IRemoteEvent <T> >(remoteEndpoint, _codec, _observerContainer, _tcpClientFactory);
            var msg = string.Format("NewClientConnection: Local {0} connected to Remote {1}",
                                    client.Link.LocalEndpoint.ToString(),
                                    client.Link.RemoteEndpoint.ToString());

            LOGGER.Log(Level.Info, msg);

            ProxyObserver remoteObserver = new ProxyObserver(client);

            return(remoteObserver);
        }
Пример #2
0
        /// <summary>
        /// Returns an IObserver used to send messages to the remote host at
        /// the specified IPEndpoint.
        /// </summary>
        /// <param name="remoteEndpoint">The IPEndpoint of the remote host</param>
        /// <returns>An IObserver used to send messages to the remote host</returns>
        public IObserver <T> GetRemoteObserver(IPEndPoint remoteEndpoint)
        {
            if (remoteEndpoint == null)
            {
                throw new ArgumentNullException("remoteEndpoint");
            }

            ProxyObserver remoteObserver;

            if (!_cachedClients.TryGetValue(remoteEndpoint, out remoteObserver))
            {
                TransportClient <IRemoteEvent <T> > client =
                    new TransportClient <IRemoteEvent <T> >(remoteEndpoint, _codec, _observerContainer);
                var msg = string.Format("NewClientConnection: Local {0} connected to Remote {1}",
                                        client.Link.LocalEndpoint.ToString(),
                                        client.Link.RemoteEndpoint.ToString());
                LOGGER.Log(Level.Info, msg);

                remoteObserver = new ProxyObserver(client);
                _cachedClients[remoteEndpoint] = remoteObserver;
            }

            return(remoteObserver);
        }
Пример #3
0
 /// <summary>
 /// Create new ProxyObserver
 /// </summary>
 /// <param name="client">The connected transport client used to send
 /// messages to remote host</param>
 public ProxyObserver(TransportClient <IRemoteEvent <T> > client)
 {
     _client       = client;
     _messageCount = 0;
 }