/// <summary> /// Registers an IObserver used to handle incoming messages from the remote host /// at the specified IPEndPoint. /// The IDisposable that is returned can be used to unregister the IObserver. /// </summary> /// <param name="remoteEndpoint">The IPEndPoint of the remote host</param> /// <param name="observer">The IObserver to handle incoming messages</param> /// <returns>An IDisposable used to unregister the observer with</returns> public IDisposable RegisterObserver(RemoteEventEndPoint <T> remoteEndpoint, IObserver <T> observer) { if (remoteEndpoint == null) { throw new ArgumentNullException("remoteEndpoint"); } SocketRemoteIdentifier id = remoteEndpoint.Id as SocketRemoteIdentifier; if (id == null) { throw new ArgumentException("ID not supported"); } return(RegisterObserver(id.Addr, observer)); }
/// <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(RemoteEventEndPoint <T> remoteEndpoint) { if (remoteEndpoint == null) { throw new ArgumentNullException("remoteEndpoint"); } SocketRemoteIdentifier id = remoteEndpoint.Id as SocketRemoteIdentifier; if (id == null) { throw new ArgumentException("ID not supported"); } return(GetRemoteObserver(id.Addr)); }