Export (0) Print
Expand All

IClientChannelSink.AsyncProcessRequest Method

Requests asynchronous processing of a method call on the current sink.

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

[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
void AsyncProcessRequest(
	IClientChannelSinkStack sinkStack,
	IMessage msg,
	ITransportHeaders headers,
	Stream stream
)

Parameters

sinkStack
Type: System.Runtime.Remoting.Channels.IClientChannelSinkStack

A stack of channel sinks that called this sink.

msg
Type: System.Runtime.Remoting.Messaging.IMessage

The message to process.

headers
Type: System.Runtime.Remoting.Channels.ITransportHeaders

The headers to add to the outgoing message heading to the server.

stream
Type: System.IO.Stream

The stream headed to the transport sink.

ExceptionCondition
SecurityException

The immediate caller does not have infrastructure permission.

[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)]
internal class MyClientFormatterChannelSink :
         BaseChannelSinkWithProperties, IClientChannelSink, IMessageSink
{
   private IClientChannelSink nextClientSink=null;
   private IMessageSink nextMessageSink = null;

   public MyClientFormatterChannelSink(IClientChannelSink nextSink,
                                       IMessageSink nextMsgSink) : base()
   {
      nextClientSink = nextSink;
      nextMessageSink = nextMsgSink;
   }

   public void ProcessMessage(IMessage msg,
         ITransportHeaders requestHeaders, Stream requestStream,
         out ITransportHeaders responseHeaders, out Stream responseStream)
   {
      nextClientSink.ProcessMessage(msg, requestHeaders, requestStream,
               out responseHeaders, out responseStream);
   }

   public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                  IMessage msg, ITransportHeaders headers, Stream myStream)
   {
      sinkStack.Push(this, null);
      nextClientSink.AsyncProcessRequest(sinkStack,msg,headers,myStream);
   }

   public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack,
         Object state, ITransportHeaders headers, Stream myStream)
   {
      sinkStack.AsyncProcessResponse(headers, myStream);
   }

   public Stream GetRequestStream(IMessage msg,ITransportHeaders headers)
   {
      return null;
   }

   public IClientChannelSink NextChannelSink
   {
      get
      {
         return nextClientSink;
      }
   }

   public IMessageSink NextSink
   {
      get
      {
         return nextMessageSink;
      }
   }

   public IMessageCtrl AsyncProcessMessage(IMessage msg,
                                                IMessageSink replySink)
   {
      return null;
   }

   public IMessage SyncProcessMessage(IMessage msg)
   {
      return nextMessageSink.SyncProcessMessage(msg);
   }

   public override Object this[Object key]
   {
      get
      {
         if (key == typeof(MyKey))
            return this;
         return null;
      }
      set
      {
         throw new NotSupportedException();
      }
   }
   public override ICollection Keys
   {
      get
      {
         ArrayList myKeys = new ArrayList(1);
         myKeys.Add(typeof(MyKey));
         return myKeys;
      }
   }
}
public class MyKey
{
}
public __gc class MyKey
{
};

private __gc class MyClientFormatterChannelSink :
    public BaseChannelSinkWithProperties, public IClientChannelSink, public IMessageSink
{
private:
    IClientChannelSink* nextClientSink;
    IMessageSink* nextMessageSink;

public:
    MyClientFormatterChannelSink() : nextClientSink(0), nextMessageSink(0) {}

    MyClientFormatterChannelSink(IClientChannelSink* nextSink,
        IMessageSink* nextMsgSink) : BaseChannelSinkWithProperties()
    {
        nextClientSink = nextSink;
        nextMessageSink = nextMsgSink;
    }

    void ProcessMessage(IMessage* msg,
        ITransportHeaders* requestHeaders, Stream* requestStream,
        [Out]ITransportHeaders** responseHeaders, [Out]Stream** responseStream)
    {
        nextClientSink->ProcessMessage(msg, requestHeaders, requestStream,
            responseHeaders, responseStream);
    }

    void AsyncProcessRequest(IClientChannelSinkStack* sinkStack,
        IMessage* msg, ITransportHeaders* headers, Stream* myStream)
    {
        sinkStack->Push(this, 0);
        nextClientSink->AsyncProcessRequest(sinkStack,msg,headers,myStream);
    }

    void AsyncProcessResponse(IClientResponseChannelSinkStack* sinkStack,
        Object* /*state*/, ITransportHeaders* headers, Stream* myStream)
    {
        sinkStack->AsyncProcessResponse(headers, myStream);
    }

    Stream* GetRequestStream(IMessage* /*msg*/,ITransportHeaders* /*headers*/)
    {
        return 0;
    }

    __property IClientChannelSink* get_NextChannelSink()
    {
        return nextClientSink;
    }

    __property IMessageSink* get_NextSink()
    {
        return nextMessageSink;
    }

    IMessageCtrl* AsyncProcessMessage(IMessage* /*msg*/,
        IMessageSink* /*replySink*/)
    {
        return 0;
    }

    IMessage* SyncProcessMessage(IMessage* msg)
    {
        return nextMessageSink->SyncProcessMessage(msg);
    }

    __property Object* get_Item( Object* key )
    {
        if (key == __typeof(MyKey))
            return this;
        return 0;
    }

    __property void set_Item( Object* /*value*/, Object* /*key*/ )
    {
        throw new NotSupportedException();
    }

    __property ICollection* get_Keys()
    {
        ArrayList* myKeys = new ArrayList(1);
        myKeys->Add(__typeof(MyKey));
        return myKeys;
    }

};

public __gc class MyClientFormatterProvider : public IClientChannelSinkProvider
{
private:
    IClientChannelSinkProvider* nextProvider;
public:
    MyClientFormatterProvider() : nextProvider(0)
    {
    }

    IClientChannelSink* CreateSink(IChannelSender* channel,
        String* myUrl, Object* remoteChannelData)
    {
        IClientChannelSink* nextSink = 0;
        IMessageSink* nextMsgSink = 0;
        if (nextProvider!=0)
        {
            Console::WriteLine(S"Next client sink provider is: {0}", nextProvider);
            // Create a sink chain calling the next sink provider's
            // 'CreateSink' method.
            nextSink=nextProvider->CreateSink(channel,myUrl,remoteChannelData);
            nextMsgSink=dynamic_cast<IMessageSink*>(nextSink);
        }
        return new MyClientFormatterChannelSink(nextSink,nextMsgSink);
    }

    __property IClientChannelSinkProvider* get_Next()
    {
        return nextProvider;
    }

    __property void set_Next( IClientChannelSinkProvider* value )
    {
        nextProvider = value;
    }

};

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft