Szerkesztés

Megosztás a következőn keresztül:


TcpChannel.CreateMessageSink(String, Object, String) Method

Definition

Returns a channel message sink that delivers messages to the specified URL or channel data object.

public:
 virtual System::Runtime::Remoting::Messaging::IMessageSink ^ CreateMessageSink(System::String ^ url, System::Object ^ remoteChannelData, [Runtime::InteropServices::Out] System::String ^ % objectURI);
public System.Runtime.Remoting.Messaging.IMessageSink CreateMessageSink (string url, object remoteChannelData, out string objectURI);
abstract member CreateMessageSink : string * obj * string -> System.Runtime.Remoting.Messaging.IMessageSink
override this.CreateMessageSink : string * obj * string -> System.Runtime.Remoting.Messaging.IMessageSink
Public Function CreateMessageSink (url As String, remoteChannelData As Object, ByRef objectURI As String) As IMessageSink

Parameters

url
String

The URL to which the new sink should deliver messages. Can be null.

remoteChannelData
Object

The channel data object of the remote host to which the new sink should deliver messages. Can be null.

objectURI
String

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.

Returns

A channel message sink that delivers messages to the specified URL or channel data object.

Implements

Examples

The following code example shows how to use this method.

// Create a message sink.
String^ objectUri;
System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = 
    clientChannel->CreateMessageSink(
        "tcp://localhost:9090/RemoteObject.rem", nullptr,
        objectUri);
Console::WriteLine("The URI of the message sink is {0}.", 
    objectUri);
if (messageSink != nullptr)
{
    Console::WriteLine("The type of the message sink is {0}.", 
        messageSink->GetType()->ToString());
}
// Create a message sink.
string objectUri;
System.Runtime.Remoting.Messaging.IMessageSink messageSink =
    clientChannel.CreateMessageSink(
        "tcp://localhost:9090/RemoteObject.rem", null,
        out objectUri);
Console.WriteLine("The URI of the message sink is {0}.",
    objectUri);
if (messageSink != null)
{
    Console.WriteLine("The type of the message sink is {0}.",
        messageSink.GetType().ToString());
}

Remarks

The CreateMessageSink method returns a channel message sink that delivers messages to either the specified URL or channel data object. If the uri parameter is null, remoteChannelData is used as a target for the sink. Either the url or remoteChannelData parameters can be null, but not both.

Channel sinks provide a plug-in point that allows access to the underlying messages flowing through the channel as well as the stream used by the transport mechanism to send messages to a remote object. Channel sinks are linked together in a chain of ChannelSinkProviders and all channel messages flow through this chain of sinks before the message is finally serialized and transported.

Applies to