English 中文(简体)
Where is Transparent Proxy pointing to?
原标题:

I am using .Net Remoting. I have a service exposing a singleton class that a client on another machine can register with, so that the server can broadcast messsages to all registered clients.

  MessageManager mgr = MessageManager.Instance; //Static Singleton Factory Proprty
  RemotingServices.Marshal(mgr, MesgURI);

Now in my service, in the method where I am publishing these messages, I want to stop the code from sending the same message to the same client more than once. So I am iterating through the server s delegate.InvocationList

public event MessageArrived SendMsgToClientEvent;
Delegate[] clientList = SendMsgToClientEvent.GetInvocationList();
List<int> dels = new List<int>();
foreach (Delegate d in clientList)
    try
    {
       mAH = (MessageArrived)d;
       int tgtHC = mAH.Target.GetHashCode();
       if (dels.Contains(tgtHC))        // If we already sent  
           SendMsgToClientEvent -= mAH; // to this one, delete it
       else 
       {
          mAH.BeginInvoke(msg, OnMsgCallComplete, null);
          dels.Add(tgtHC);    // keep track of which ones we ve sent to
       }
    }
    // ..... 

Now each delegate mAH contains a method (which will be called when the delegate is invoked) It also contains a Target property, which, (for instance methods), is populated with a reference to the object that this method will be called against.

But for remote events like this, the delegate has been populated by event registrations from remote clients, over a .Net Remoting channel. So in this case, this target Property is populated with a Transparent Proxy object, not the object on the remote client box where the handler will actually be executed. So my assumption is that even if two delegate registrations come from the same method on the same remote object, they will each still get distinct individual transparent proxies on the server. Now what I want to do is ensure that if a specific client somehow registers more than once, that the server does not transmit the same message more than once to that client. (...and then remove that extra delegate from the invocation List).

So my question is: How can I tell, from looking at the delegate, or from the transparent proxy in the delegates Target Property, that two such delegates are actually from the same object on the same client machine?

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签