IChannelReceiver 인터페이스

정의

수신기 채널에 필요한 함수와 속성을 제공합니다.

public interface class IChannelReceiver : System::Runtime::Remoting::Channels::IChannel
public interface IChannelReceiver : System.Runtime.Remoting.Channels.IChannel
[System.Runtime.InteropServices.ComVisible(true)]
public interface IChannelReceiver : System.Runtime.Remoting.Channels.IChannel
type IChannelReceiver = interface
    interface IChannel
[<System.Runtime.InteropServices.ComVisible(true)>]
type IChannelReceiver = interface
    interface IChannel
Public Interface IChannelReceiver
Implements IChannel
파생
특성
구현

예제

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 !!!" );
      }
   }
};
class MyCustomChannel : IChannelReceiver
{
   private ChannelDataStore myChannelData;
   private int myChannelPriority = 25;
   // Set the 'ChannelName' to 'MyCustomChannel'.
   private string myChanneName = "tcp";
   // Implement 'ChannelName' property.
   private TcpListener myTcpListener;
   private int myPortNo;
   private bool myListening = false;
   private Thread myThread;
   public MyCustomChannel(int portNo)
   {
      myPortNo = portNo;
      string [] myURI = new string[1];
      myURI[0] = Dns.Resolve(Dns.GetHostName()).AddressList[0] + ":" +
                                                         portNo.ToString();
      // Store the 'URI' in 'myChannelDataStore'.
      myChannelData = new ChannelDataStore(myURI);
      // Create 'myTcpListener' to listen at the 'myPortNo' port.
      myTcpListener = new TcpListener(myPortNo);
      // Create the thread 'myThread'.
      myThread = new Thread(new ThreadStart(myTcpListener.Start));
      this.StartListening(null);
   }
   public string ChannelName
   {
      get
      {
         return myChanneName;
      }
   }
   public int ChannelPriority
   {
      get
      {
         return myChannelPriority;
      }
   }
   public string Parse(string myUrl, out string objectURI)
   {
      Regex myRegex = new 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.
   public object ChannelData
   {
      get
      {
         return myChannelData;
      }
   }

   // Create and send the object URL.
   public string[] GetUrlsForUri(string objectURI)
   {
      string[] myString = new string[1];
      myString[0] = Dns.Resolve(Dns.GetHostName()).AddressList[0]
                                                         + "/" + objectURI;
      return myString;
   }

   // Start listening to the port.
   public void StartListening(object data)
   {
      if(myListening == false)
      {
         myTcpListener.Start();
         myListening = true;
         Console.WriteLine("Server Started Listening !!!");
      }
   }

   // Stop listening to the port.
   public void StopListening(object data)
   {
      if(myListening == true)
      {
         myTcpListener.Stop();
         myListening = false;
         Console.WriteLine("Server Stopped Listening !!!");
      }
   }
}
Class MyCustomChannel
      Implements IChannelReceiver 
      Private myChannelData As ChannelDataStore
      Private myChannelPriority As Integer = 25
      ' Set the 'ChannelName' to 'MyCustomChannel'.
      Private myChanneName As String = "tcp"
      ' Implement 'ChannelName' property.
      Private myTcpListener As TcpListener
      Private myPortNo As Integer
      Private myListening As Boolean = False
      Private myThread As Thread

      Public Sub New(ByVal portNo As Integer)
         myPortNo = portNo
      Dim myURI(0) As String
      myURI(0) = Dns.Resolve(Dns.GetHostName()).AddressList(0).ToString() + ":" + _
                                                                  portNo.ToString()
      ' Store the 'URI' in 'myChannelDataStore'.
      myChannelData = New ChannelDataStore(myURI)
      ' Create 'myTcpListener' to listen at the 'myPortNo' port.
      myTcpListener = New TcpListener(myPortNo)
      ' Create the thread 'myThread'.
      myThread = New Thread(New ThreadStart(AddressOf myTcpListener.Start))
      Me.StartListening(Nothing)
      End Sub

      Public ReadOnly Property ChannelName() As String Implements IChannelReceiver.ChannelName
      Get
         Return myChanneName
      End Get
      End Property

      Public ReadOnly Property ChannelPriority() As Integer _
                                          Implements IChannelReceiver.ChannelPriority
      Get
         Return myChannelPriority
      End Get
      End Property

      Public Function Parse(ByVal myUrl As String, ByRef objectURI As String) As String _
                                                      Implements IChannelReceiver.Parse
      Dim myRegex As New Regex("/", RegexOptions.RightToLeft)
      ' Check for '/' in 'myUrl' from Right to left.
      Dim myMatch As Match = myRegex.Match(myUrl)
      ' Get the object URI.
      objectURI = myUrl.Substring(myMatch.Index)
      ' Return the channel url.
      Return myUrl.Substring(0, myMatch.Index)
      End Function 'Parse
      ' Implementation of 'IChannelReceiver' interface.

   Public ReadOnly Property ChannelData() As Object Implements IChannelReceiver.ChannelData
      Get
         Return myChannelData
      End Get
   End Property

   ' Create and send the object URL.
   Public Function GetUrlsForUri(ByVal objectURI As String) As String() _
                                             Implements IChannelReceiver.GetUrlsForUri
      Dim myString(0) As String
      myString(0) = Dns.Resolve(Dns.GetHostName()).AddressList(0).ToString() + "/" + objectURI
      Return myString
   End Function 'GetUrlsForUri

   ' Start listening to the port.
   Public Sub StartListening(ByVal data As Object) Implements IChannelReceiver.StartListening
      If myListening = False Then
          myTcpListener.Start()
          myListening = True
          Console.WriteLine("Server Started Listening !!!")
      End If
   End Sub

   ' Stop listening to the port.
   Public Sub StopListening(ByVal data As Object) Implements IChannelReceiver.StopListening
      If myListening = True Then
          myTcpListener.Stop()
          myListening = False
          Console.WriteLine("Server Stopped Listening !!!")
      End If
   End Sub
End Class

설명

채널의 수신 측을 노출 해야 합니다는 IChannelReceiver 인터페이스입니다.

속성

ChannelData

채널 관련 데이터를 가져옵니다.

ChannelName

채널 이름을 가져옵니다.

(다음에서 상속됨 IChannel)
ChannelPriority

해당 채널의 우선 순위를 가져옵니다.

(다음에서 상속됨 IChannel)

메서드

GetUrlsForUri(String)

URI에 대한 모든 URL로 이루어진 배열을 반환합니다.

Parse(String, String)

out 매개 변수로 개체 URI를 반환하고, 반환 값으로 현재 채널의 URI를 반환합니다.

(다음에서 상속됨 IChannel)
StartListening(Object)

현재 채널에게 요청 수신을 시작하도록 지시합니다.

StopListening(Object)

현재 채널에게 요청 수신을 중지하도록 지시합니다.

적용 대상