[Mono-dev] Remoting Server Events problem

buhochileno at gmail.com buhochileno at gmail.com
Sun Nov 25 14:20:43 EST 2007


Thanks Robert, I very confuse with this, becouse I read a lote of 
diferent approach (event broadcast engines, shared objects, etc) to do 
this, but most of them don't work :-S ,  I wondore if you have a simple 
working example of the correct way to do this?

in advance, thank you very much.

Mauricio

Robert Jordan wrote:
> buhochileno at gmail.com wrote:
>   
>> Hi:
>>
>> I know that is very possible that this is a basic remoting question, but 
>> I read some info about the native .NET approach used with remoting and I 
>> think that my code is supose it to work:
>>
>> I write a class with a method to trigger some event (this is the object 
>> resgitered by the remoting server):
>> [Serializable]
>> public class Camera: MarshalByRefObject
>> ...
>>    public void SetZoom(int amount)
>>    {...//zoom code
>>        SomeDelegate h = this.SomeEvent; //some test event triger, the 
>> SomeDelegate is public...
>>        if ((h != null) && (SomeEvent != null))
>>                h (this, new EventArgs());
>>        else
>>                Console.WriteLine("null then?"); //allways is null
>>       }
>> ...On the client side I use a special "RemoteCamera", this class deal 
>> with all the remoting stuff related to get the object from the 
>> server...something like:
>> [Serializable]
>> public class RemoteCamera: MarshalByRefObject
>>        public RemoteOrbitKit()
>>        { .../channel registration, etc...
>>             
>> camera(ICamerat)Activator.GetObject(typeof(ICamera),_fullObjectURLPath); 
>> //....
>>            camera.SomeEvent += new SomeDelegate(SomeMethod);
>>             ...
>>             camera.SetZoom(50); //this work, but the event is not 
>> triggered...
>>
>>        }
>>        public SomeMethod(object sender, EventArgs e)
>>        {
>>             Console.WriteLine("method called"); //This methis is never 
>> called becouse the Event/method asociation allways is null
>>        }
>>
>> Do you see what is my mistake?
>> sugestions?, ideas?
>>     
>
>
> 1. The server must know the type "RemoteCamera", because the delegate
>     is containing a reference to an instance of this class.
>
>     You can circumvent this by using a public static method as
>     an event handler.
>
> 2. The client must start a listener as well. This is done with
>     "new TcpChannel (0)" or "new HttpChannel (0)" or with a
>     corresponding remoting configuration setting.
>
> 3. The client must not be firewalled because it is
>     called back by the server.
>
> Robert
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>   




More information about the Mono-devel-list mailing list