Compartir a través de


IClientChannelSink Interfaz

Definición

Proporciona las funciones y propiedades necesarias para los receptores de canal del cliente.

public interface class IClientChannelSink : System::Runtime::Remoting::Channels::IChannelSinkBase
public interface IClientChannelSink : System.Runtime.Remoting.Channels.IChannelSinkBase
[System.Runtime.InteropServices.ComVisible(true)]
public interface IClientChannelSink : System.Runtime.Remoting.Channels.IChannelSinkBase
type IClientChannelSink = interface
    interface IChannelSinkBase
[<System.Runtime.InteropServices.ComVisible(true)>]
type IClientChannelSink = interface
    interface IChannelSinkBase
Public Interface IClientChannelSink
Implements IChannelSinkBase
Derivado
Atributos
Implementaciones

Ejemplos

En el ejemplo de código siguiente se muestra una implementación de la IClientChannelSink interfaz .

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 ClientSink: public BaseChannelSinkWithProperties, public IClientChannelSink
{
private:

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


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

   virtual Stream^ GetRequestStream( IMessage^ message, ITransportHeaders^ requestHeaders )
   {
      // Get the request stream from the next sink in the chain.
      return (nextSink->GetRequestStream( message, requestHeaders ));
   }

   virtual void ProcessMessage( IMessage^ message, ITransportHeaders^ requestHeaders, Stream^ requestStream, [Out]ITransportHeaders^% responseHeaders, [Out]Stream^% responseStream )
   {
      // Print the request message properties.
      Console::WriteLine( "---- Message from the client ----" );
      IDictionary^ dictionary = message->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( "---------------------------------" );

      // Hand off to the next sink in the chain.
      nextSink->ProcessMessage( message, requestHeaders, requestStream, responseHeaders, responseStream );
   }

   // For synchronous remoting, it is not necessary to implement this method.
   virtual void AsyncProcessRequest( IClientChannelSinkStack^ /*sinkStack*/, IMessage^ /*message*/, ITransportHeaders^ /*requestHeaders*/, Stream^ /*requestStream*/ )
   {
      throw gcnew NotImplementedException;
   }

   virtual void AsyncProcessResponse( IClientResponseChannelSinkStack^ /*sinkStack*/, Object^ /*state*/, 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
   ClientSink( IClientChannelSink^ 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 ClientSink : BaseChannelSinkWithProperties, IClientChannelSink
{

    // This class inherits from BaseChannelSinkWithPropertes
    // to get an implementation of IChannelSinkBase.

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

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

    public Stream GetRequestStream (IMessage message, ITransportHeaders requestHeaders)
    {
        // Get the request stream from the next sink in the chain.
        return( nextSink.GetRequestStream(message, requestHeaders) );
    }

    public void ProcessMessage (IMessage message,
                                ITransportHeaders requestHeaders,
                                Stream requestStream,
                                out ITransportHeaders responseHeaders,
                                out Stream responseStream)
    {
        // Print the request message properties.
        Console.WriteLine("---- Message from the client ----");
        IDictionary dictionary = message.Properties;
        foreach (Object key in dictionary.Keys)
        {
            Console.WriteLine("{0} = {1}", key, dictionary[key]);
        }
        Console.WriteLine("---------------------------------");

        // Hand off to the next sink in the chain.
        nextSink.ProcessMessage(message, requestHeaders, requestStream, out responseHeaders, out responseStream);
    }

    // For synchronous remoting, it is not necessary to implement this method.
    public void AsyncProcessRequest (IClientChannelSinkStack sinkStack,
                                     IMessage message,
                                     ITransportHeaders requestHeaders,
                                     Stream requestStream)
    {
        throw new NotImplementedException();
    }

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

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

Consulte la documentación de la IClientChannelSinkProvider interfaz para obtener un ejemplo de la implementación del proveedor de receptores de cliente correspondiente.

Comentarios

Los receptores de canal proporcionan un punto de complemento que permite el acceso a los mensajes subyacentes que fluyen a través del canal, así como la secuencia usada por el mecanismo de transporte para enviar mensajes a un objeto remoto. Los receptores de canal se vinculan juntos en una cadena de proveedores receptores de canal y todos los mensajes de canal fluyen a través de esta cadena de receptores antes de serializarlos y transportarlos.

Propiedades

NextChannelSink

Obtiene el siguiente receptor de canal del cliente de la cadena de receptores del cliente.

Properties

Obtiene un diccionario a través del cual se puede obtener acceso a las propiedades del receptor.

(Heredado de IChannelSinkBase)

Métodos

AsyncProcessRequest(IClientChannelSinkStack, IMessage, ITransportHeaders, Stream)

Solicita el procesamiento asincrónico de una llamada a un método en el receptor actual.

AsyncProcessResponse(IClientResponseChannelSinkStack, Object, ITransportHeaders, Stream)

Solicita el procesamiento asincrónico de una respuesta a una llamada a un método en el receptor actual.

GetRequestStream(IMessage, ITransportHeaders)

Devuelve el objeto Stream donde se va a serializar el mensaje especificado.

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

Solicita el procesamiento de mensajes del receptor actual.

Se aplica a

Consulte también