Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Custom Sinks

Custom Sinks

Scheduled Pinned Locked Moved C#
tutorialquestionsysadmindata-structures
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    esjq
    wrote on last edited by
    #1

    How do I put additional data in the request header array and how do I pick up that information on the server side? I've created a custom sink and now I want to put data in the request header array to be able to pass additional information to the server side. But I don't know how to do it and I haven't found any descriptive example. I thought that the ProcessMessage method on the client side was used to do it. But as I also has the IMessageSink.SyncProcessMessage in the class, it seems that the ProcessMessage method is never called. I've seen examples (though I don't know if the work), where the request header array is assigned data on the client side, and the array is read on the server side. But those examples don't have the sink class inhereting from IMessageSink. Any advice or example is helpful, thank you :)

    E 1 Reply Last reply
    0
    • E esjq

      How do I put additional data in the request header array and how do I pick up that information on the server side? I've created a custom sink and now I want to put data in the request header array to be able to pass additional information to the server side. But I don't know how to do it and I haven't found any descriptive example. I thought that the ProcessMessage method on the client side was used to do it. But as I also has the IMessageSink.SyncProcessMessage in the class, it seems that the ProcessMessage method is never called. I've seen examples (though I don't know if the work), where the request header array is assigned data on the client side, and the array is read on the server side. But those examples don't have the sink class inhereting from IMessageSink. Any advice or example is helpful, thank you :)

      E Offline
      E Offline
      esjq
      wrote on last edited by
      #2

      The crucial thing here, is where the custom sink is intended to be placed. That is, before or after the formatter sink. If the custom sink is placed before the formatter, you work on the message. On the other hand, if the custom sink is placed after the formatter, you work on the stream. My intentions was to have my custom sink "above" the formatter sink. And, if the first client sink shall be placed "above" the formatter sink, the IMessage interface needs to be implemented. This was why I had IMessageSink.SyncProcessMessage method in my class of course. In this situation you work on the message, and any manipulation to the message is done in the IMessageSink.SyncProcessMessage (or IMessageSink.AsyncProcessMessage) method. That's why the ProcessMessage method on the client side never was called. This code snippet shows how to add some information to the message: public IMessage SyncProcessMessage(IMessage msg) { msg.Properties.Add("Animal", "Fox"); IMessage retMsg = ((IMessageSink) nextSink).SyncProcessMessage(msg); return retMsg; } If you rather have your custom sink after the formatter sink, then it is the ProcessMessage method you're supposed to use. If so, the IMessageSink.SyncProcessMessage is not called. In this case you manipulate the array header to pass information to the server side, as follows: public void ProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, out ITransportHeaders responseHeaders, out System.IO.Stream responseStream) { requestHeaders["Animal"] = "Fox"; nextSink.ProcessMessage(msg, requestHeaders, requestStream, out responseHeaders, out responseStream); } In both cases, the ProcessMessage method on the server side is responsible to get the added information. But you use requestHeaders if you working on the stream, or the requestMsg if you're working on the message. public ProcessMessage(IServerChannelSinkStack sinkStack, System.Runtime.Remoting.Messaging.IMessage requestMsg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, out System.Runtime.Remoting.Messaging.IMessage responseMsg, out ITransportHeaders responseHeaders, out System.IO.Stream responseStream) { string msg = requestHeaders["Animal"] as string; // stream msg = requestMsg.Properties["Animal"] as string; // message ... ... }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups