다음을 통해 공유


IServerChannelSink 인터페이스

정의

보안 및 전송 싱크에 사용할 메서드를 제공합니다.

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

예제

다음 코드 예제 구현의 IServerChannelSink 인터페이스입니다.

using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Collections;
using namespace System::IO;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Messaging;

[System::Security::Permissions::PermissionSet(System::Security::
   Permissions::SecurityAction::Demand, Name = "FullTrust")]
public ref class ServerSink: public BaseChannelSinkWithProperties, public IServerChannelSink
{
private:

   // This class inherits from BaseChannelSinkWithPropertes
   // to get an implementation of IChannelSinkBase.
   // The next sink in the chain.
   IServerChannelSink^ nextSink;

public:
   property IServerChannelSink^ NextChannelSink 
   {
      virtual IServerChannelSink^ get()
      {
         return (nextSink);
      }
   }

   virtual Stream^ GetResponseStream( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*message*/, ITransportHeaders^ /*responseHeaders*/ )
   {
      return nullptr;
   }

   virtual ServerProcessing ProcessMessage( IServerChannelSinkStack^ sinkStack, IMessage^ requestMessage, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]IMessage^% responseMessage, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream )
   {
      // Hand off to the next sink for processing.
      sinkStack->Push( this, nullptr );
      ServerProcessing status = nextSink->ProcessMessage( sinkStack, requestMessage, requestHeaders, requestStream, responseMessage, responseHeaders, responseStream );

      // Print the response message properties.
      Console::WriteLine( "---- Message from the server ----" );
      IDictionary^ dictionary = ( *responseMessage).Properties;
      IEnumerator^ myEnum = dictionary->Keys->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         Object^ key = safe_cast<Object^>(myEnum->Current);
         Console::WriteLine( "{0} = {1}", key, dictionary[ key ] );
      }

      Console::WriteLine( "---------------------------------" );
      return (status);
   }

   virtual void AsyncProcessResponse( IServerResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, IMessage^ /*message*/, ITransportHeaders^ /*responseHeaders*/, Stream^ /*responseStream*/ )
   {
      throw gcnew NotImplementedException;
   }

   property System::Collections::IDictionary^ Properties 
   {
      virtual System::Collections::IDictionary^ get() override
      {
         return (dynamic_cast<BaseChannelSinkWithProperties^>(this))->Properties;
      }
   }

   // Constructor
   ServerSink( IServerChannelSink^ sink )
   {
      if ( sink == nullptr )
            throw gcnew ArgumentNullException( "sink" );

      nextSink = sink;
   }
};
using System;
using System.Collections;
using System.IO;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Messaging;

public class ServerSink : BaseChannelSinkWithProperties, IServerChannelSink
{
    // This class inherits from BaseChannelSinkWithProperties
    // to get an implementation of IChannelSinkBase.

    // The next sink in the chain.
    private IServerChannelSink nextSink;

    public IServerChannelSink NextChannelSink
    {
        get
        {
            return(nextSink);
        }
    }

    public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack,
                                     Object state,
                                     IMessage message,
                                     ITransportHeaders responseHeaders)
    {
        return(null);
    }

    public ServerProcessing ProcessMessage (IServerChannelSinkStack sinkStack,
                                            IMessage requestMessage,
                                            ITransportHeaders requestHeaders,
                                            Stream requestStream,
                                            out IMessage responseMessage,
                                            out ITransportHeaders responseHeaders,
                                            out Stream responseStream)
    {

        // Hand off to the next sink for processing.
        sinkStack.Push(this, null);
        ServerProcessing status = nextSink.ProcessMessage(
          sinkStack, requestMessage, requestHeaders, requestStream,
          out responseMessage, out responseHeaders, out responseStream
        );

        // Print the response message properties.
        Console.WriteLine("---- Message from the server ----");
        IDictionary dictionary = responseMessage.Properties;
        foreach (Object key in dictionary.Keys)
        {
            Console.WriteLine("{0} = {1}", key, dictionary[key]);
        }
        Console.WriteLine("---------------------------------");

        return(status);
    }

    public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack,
                                      Object state,
                                      IMessage message,
                                      ITransportHeaders responseHeaders,
                                      Stream responseStream)
    {
        throw new NotImplementedException();
    }

    // Constructor
    public ServerSink (IServerChannelSink sink) {
      if (sink == null) throw new ArgumentNullException("sink");
      nextSink = sink;
    }
}

참조 된 IServerChannelSinkProvider 인터페이스 구현의 예제는 해당 서버 싱크 공급자에 대 한 설명서입니다.

설명

채널 싱크는 채널 뿐만 아니라 원격 개체에 메시지를 보내는 데 전송 메커니즘을 통해 스트림을 통해 전송 되는 기본 메시지에 대 한 액세스를 허용 하는 플러그 인 지점을 제공 합니다. 채널 싱크는 채널 싱크 공급자 체인에 함께 연결 하 고 최종적으로 직렬화 되 고 전송 하기 전에이 싱크 체인을 통해 전달 되는 모든 채널 메시지입니다.

속성

NextChannelSink

서버 싱크 체인에 있는 다음 서버 채널 싱크를 가져옵니다.

Properties

싱크의 속성에 액세스할 수 있도록 하는 사전을 가져옵니다.

(다음에서 상속됨 IChannelSinkBase)

메서드

AsyncProcessResponse(IServerResponseChannelSinkStack, Object, IMessage, ITransportHeaders, Stream)

보내진 메서드 호출에 대한 응답을 현재 싱크에서 비동기식으로 처리하도록 요청합니다.

GetResponseStream(IServerResponseChannelSinkStack, Object, IMessage, ITransportHeaders)

제공된 응답 메시지가 serialize될 Stream을 반환합니다.

ProcessMessage(IServerChannelSinkStack, IMessage, ITransportHeaders, Stream, IMessage, ITransportHeaders, Stream)

현재 싱크에서 메시지 처리를 요청합니다.

적용 대상