discovery - WCF: How to set AnnouncementService only receive localhost on/off line message -


i create wcf-lib, want interprocess communication. when open app, use lib, announce each other. use udpannouncementendpoint, work. receive announcement intranet. can ?

and create endpoint code this:

    private void actioninitclientservice()     {         // create clientselt servicehost         _clientservicehost = new servicehost(_clientinstance);         _clientservicehost.addserviceendpoint((typeof (iclientservice)), new netnamedpipebinding(), info.address);          // make client discoverable via udp         // , broadcast online announcement         _clientservicehost.addserviceendpoint(new udpdiscoveryendpoint());         var discoverybehavior = new servicediscoverybehavior();         discoverybehavior.announcementendpoints.add(new udpannouncementendpoint());         _clientservicehost.description.behaviors.add(discoverybehavior);          _clientservicehost.opened += onopenedclientservicehost;         _clientservicehost.closed += onclosedclientservicehost;     } 

and add announcementslistener in host:

    private void actioninitannouncementslistener()     {         var announcementservice = new announcementservice();         announcementservice.onlineannouncementreceived += ononlineannouncementreceived;         announcementservice.offlineannouncementreceived += onofflineannouncementreceived;          _announcementslistener = new servicehost(announcementservice);         _announcementslistener.addserviceendpoint(new udpannouncementendpoint());     } 

i apologize, looking @ wrong part of code. not using named pipes in order make client discoverable.

here how can ip address of incoming message (i assume based on ip address can deduce using code logic if message comes intranet or not).

operationcontext context = operationcontext.current; messageproperties messageproperties = context.incomingmessageproperties; remoteendpointmessageproperty endpointproperty = messageproperties[remoteendpointmessageproperty.name] remoteendpointmessageproperty; 

the above code founnd on following link: http://social.msdn.microsoft.com/forums/en-us/wcf/thread/f14520be-d77d-401f-b339-9c58585857f7/

you cana find more in depth details on http://www.danrigsby.com/blog/index.php/2008/08/20/observableservicehost-an-instancecontext-creation-aware-wcf-servicehost/.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -