예제 #1
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);

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

            return(remoteObserver);
        }
예제 #2
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;
 }