2 // System.Runtime.Remoting.ServerObjectTerminatorSink.cs
4 // Author: Lluis Sanchez Gual (lsg@ctv.es)
6 // (C) 2002, Lluis Sanchez Gual
11 namespace System.Runtime.Remoting.Messaging
13 // The final sink of the Server Object Sink Chain.
14 // It invokes object dynamic sinks and forwards the message
15 // to the StackBuilderSink
17 internal class ServerObjectTerminatorSink: IMessageSink
19 IMessageSink _nextSink;
21 public ServerObjectTerminatorSink(IMessageSink nextSink)
26 public IMessage SyncProcessMessage (IMessage msg)
28 ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
29 identity.NotifyServerDynamicSinks (true, msg, false, false);
30 IMessage res = _nextSink.SyncProcessMessage (msg);
31 identity.NotifyServerDynamicSinks (false, msg, false, false);
35 public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
37 ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
38 if (identity.HasServerDynamicSinks)
40 identity.NotifyServerDynamicSinks (true, msg, false, true);
41 IMessage res = _nextSink.SyncProcessMessage (msg);
42 replySink = new ServerObjectReplySink(identity, replySink);
44 return _nextSink.AsyncProcessMessage (msg, replySink);
47 public IMessageSink NextSink
49 get { return _nextSink; }
53 class ServerObjectReplySink: IMessageSink
55 IMessageSink _replySink;
56 ServerIdentity _identity;
58 public ServerObjectReplySink (ServerIdentity identity, IMessageSink replySink)
60 _replySink = replySink;
64 public IMessage SyncProcessMessage (IMessage msg)
66 _identity.NotifyServerDynamicSinks (false, msg, true, true);
67 return _replySink.SyncProcessMessage (msg);
70 public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
72 throw new NotSupportedException ();
75 public IMessageSink NextSink
77 get { return _replySink; }