/// <summary> /// Stops listening of a specified channel. /// </summary> /// <param name="channel">TcpEx Channel</param> /// <param name="listenerAddresses">Addresses the channel is listening</param> public static void StopListening(TcpExChannel channel, string[] listenerAddresses) { if (channel == null) { throw new ArgumentNullException("channel"); } // close running connections var runningConnections = Connection.GetRunningConnectionsOfChannel(channel); if (runningConnections != null) { while (runningConnections.Count() > 0) { runningConnections.First().Close(); } } // remove pending listeners if specified if (listenerAddresses != null) { lock (_listenersLockObject) { foreach (var address in listenerAddresses) { _listeners.Remove(address); } } } }
/// <summary> /// Stops listening of a specified channel. /// </summary> /// <param name="channel">TcpEx Channel</param> public static void StopListening(TcpExChannel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } var runningConnections = Connection.GetRunningConnectionsOfChannel(channel); if (runningConnections != null) { while (runningConnections.Count() > 0) { runningConnections.First().Close(); } } }
/// <summary> /// Returns a channel message sink that delivers messages to the specified URL or channel data object. /// </summary> /// <param name="url">The URL to which the new sink will deliver messages. Can be null.</param> /// <param name="remoteChannelData">The channel data object of the remote host to which the new sink will deliver messages. Can be null.</param> /// <param name="objectURI">When this method returns, contains a URI of the new channel message sink that delivers messages to the specified URL or channel data object. This parameter is passed uninitialized.</param> /// <returns> /// A channel message sink that delivers messages to the specified URL or channel data object, or null if the channel cannot connect to the given endpoint. /// </returns> /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception> public IMessageSink CreateMessageSink(string url, object remoteChannelData, out string objectURI) { objectURI = null; if (url == null) { var channelData = remoteChannelData as TcpExChannelData; if (channelData == null) { // unsupported ChannelData object return(null); } var connections = Connection.GetRunningConnectionsOfChannel(this); if (connections.All(c => c.RemoteChannelID != channelData.ChannelID)) { // unknown channel identity return(null); } // known channel is establishing back connection to us url = Manager.CreateUrl(LocalCallContextData.GetData("RemoteChannelID", channelData.ChannelID)); } if (Manager.Parse(url, out objectURI) != null) { IClientChannelSink clientChannelSink = clientSinkProvider.CreateSink(this, url, remoteChannelData); IMessageSink messageSink = clientChannelSink as IMessageSink; if (clientChannelSink != null && messageSink == null) { throw new RemotingException(LanguageResource.RemotingException_MessageSinkNotSet); } return(messageSink); } else { // unsupported URL format return(null); } }