This documentation is archived and is not being maintained.
IChannelReceiver Interface
Visual Studio 2010
Provides required functions and properties for the receiver channels.
Assembly: mscorlib (in mscorlib.dll)
The IChannelReceiver type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ChannelData | Gets the channel-specific data. |
![]() | ChannelName | Gets the name of the channel. (Inherited from IChannel.) |
![]() | ChannelPriority | Gets the priority of the channel. (Inherited from IChannel.) |
| Name | Description | |
|---|---|---|
![]() | GetUrlsForUri | Returns an array of all the URLs for a URI. |
![]() | Parse | Returns the object URI as an out parameter, and the URI of the current channel as the return value. (Inherited from IChannel.) |
![]() | StartListening | Instructs the current channel to start listening for requests. |
![]() | StopListening | Instructs the current channel to stop listening for requests. |
ref class MyCustomChannel: public IChannelReceiver { private: ChannelDataStore^ myChannelData; int myChannelPriority; // Set the 'ChannelName' to 'MyCustomChannel'. String^ myChannelName; // Implement 'ChannelName' property. TcpListener^ myTcpListener; int myPortNo; bool myListening; Thread^ myThread; public: MyCustomChannel() : myChannelPriority( 25 ), myChannelName( "tcp" ), myListening( false ) {} MyCustomChannel( int portNo ) { myPortNo = portNo; array<String^>^myURI = gcnew array<String^>(1); myURI[ 0 ] = String::Concat( Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ], ":", portNo ); // Store the 'URI' in 'myChannelDataStore'. myChannelData = gcnew ChannelDataStore( myURI ); // Create 'myTcpListener' to listen at the 'myPortNo' port. myTcpListener = gcnew TcpListener( myPortNo ); // Create the thread 'myThread'. myThread = gcnew Thread( gcnew ThreadStart( myTcpListener, &TcpListener::Start ) ); this->StartListening( nullptr ); } property String^ ChannelName { virtual String^ get() { return myChannelName; } } property int ChannelPriority { virtual int get() { return myChannelPriority; } } virtual String^ Parse( String^ myUrl, [Out]String^% objectURI ) { Regex^ myRegex = gcnew Regex( "/",RegexOptions::RightToLeft ); // Check for '/' in 'myUrl' from Right to left. Match^ myMatch = myRegex->Match(myUrl); // Get the object URI. objectURI = myUrl->Substring( myMatch->Index ); // Return the channel url. return myUrl->Substring( 0, myMatch->Index ); } // Implementation of 'IChannelReceiver' interface. property Object^ ChannelData { virtual Object^ get() { return myChannelData; } } // Create and send the object URL. virtual array<String^>^ GetUrlsForUri( String^ objectURI ) { array<String^>^myString = gcnew array<String^>(1); myString[ 0 ] = String::Concat( Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ], "/", objectURI ); return myString; } // Start listening to the port. virtual void StartListening( Object^ data ) { if ( myListening == false ) { myTcpListener->Start(); myListening = true; Console::WriteLine( "Server Started Listening !!!" ); } } // Stop listening to the port. virtual void StopListening( Object^ data ) { if ( myListening == true ) { myTcpListener->Stop(); myListening = false; Console::WriteLine( "Server Stopped Listening !!!" ); } } };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
