IChannelSender Interface

 

Provides required functions and properties for the sender channels.

Namespace:   System.Runtime.Remoting.Channels
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)]
public interface class IChannelSender : IChannel

NameDescription
System_CAPS_pubpropertyChannelName

Gets the name of the channel.(Inherited from IChannel.)

System_CAPS_pubpropertyChannelPriority

Gets the priority of the channel.(Inherited from IChannel.)

NameDescription
System_CAPS_pubmethodCreateMessageSink(String^, Object^, String^%)

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

System_CAPS_pubmethodParse(String^, String^%)

Returns the object URI as an out parameter, and the URI of the current channel as the return value.(Inherited from IChannel.)

The sending side of channels must expose the IChannelSender interface.

#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <IChannelSender_Share.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Messaging;
using namespace System::Runtime::Remoting::Channels::Http;
int main()
{
   try
   {

      // Create the 'IDictionary' to set the server object properties.
      IDictionary^ myDictionary = gcnew Hashtable;
      myDictionary->default[ "name" ] = "HttpClientChannel";
      myDictionary->default[ "priority" ] = 2;

      // Set the properties along with the constructor.
      IChannelSender^ myIChannelSender = gcnew HttpClientChannel( myDictionary,gcnew BinaryClientFormatterSinkProvider );

      // Register the server channel.
      ChannelServices::RegisterChannel( myIChannelSender, false );
	  MyHelloServer ^ myHelloServer1 = dynamic_cast<MyHelloServer^>(Activator::GetObject( MyHelloServer::typeid, "http://localhost:8085/SayHello" ));
      if ( myHelloServer1 == nullptr )
      {
         Console::WriteLine( "Could not locate server" );
      }
      else
      {
         Console::WriteLine( myHelloServer1->myHelloMethod( "Client" ) );

         // Get the name of the channel.
         Console::WriteLine( "Channel Name :{0}", myIChannelSender->ChannelName );

         // Get the channel priority.
         Console::WriteLine( "ChannelPriority :{0}", myIChannelSender->ChannelPriority );
         String^ myString;
         String^ myObjectURI1;
         Console::WriteLine( "Parse :{0}{1}", myIChannelSender->Parse( "http://localhost:8085/SayHello",  myString ), myString );

         // Get the channel message sink that delivers message to specified url.
         IMessageSink^ myIMessageSink = myIChannelSender->CreateMessageSink( "http://localhost:8085/NewEndPoint", nullptr,  myObjectURI1 );
         Console::WriteLine( "Channel message sink used :{0}", myIMessageSink );

         Console::WriteLine( "URI of new channel message sink :{0}", myObjectURI1 );
      }
   }
   catch ( Exception^ ex ) 
   {
      Console::WriteLine( "Following exception is raised on client side : {0}", ex->Message );
   }

}

.NET Framework
Available since 1.1
Return to top
Show: