/// <summary> /// Starts this instance. /// </summary> public void Start() { announcementService = new AnnouncementService(); announcementService.OnlineAnnouncementReceived += OnClientNotificationReceived; announcementServiceHost = new ServiceHost(announcementService); announcementServiceHost.AddServiceEndpoint(new UdpAnnouncementEndpoint()); announcementServiceHost.Open(); }
private void MonitorAnnouncements(ServiceHost serviceHost) { var announcements = new AnnouncementService(); announcementHost = new ServiceHost(announcements, new Uri[0]); announcementHost.Description.Behaviors.Find<ServiceBehaviorAttribute>().UseSynchronizationContext = false; announcementHost.AddServiceEndpoint(UdpAnnouncementEndpoint ?? new UdpAnnouncementEndpoint()); announcements.OnlineAnnouncementReceived += (_, args) => RegisterService(serviceHost, args.EndpointDiscoveryMetadata); announcements.OfflineAnnouncementReceived += (_, args) => RemoveService(serviceHost, args.EndpointDiscoveryMetadata); announcementHost.Open(); }
public AnnouncementBoundDiscoveryService (AnnouncementEndpoint aendpoint) { var ans = new AnnouncementService (); ans.OnlineAnnouncementReceived += RegisterEndpoint; ans.OfflineAnnouncementReceived += UnregisterEndpoint; ahost = new ServiceHost (ans); ahost.AddServiceEndpoint (aendpoint); ahost.Description.Behaviors.Find<ServiceDebugBehavior> ().IncludeExceptionDetailInFaults = true; ahost.Open (); foreach (var cd in ahost.ChannelDispatchers) TextWriter.Null.WriteLine ("AnnouncementService.ChannelDispatcher " + cd.Listener.Uri); }
public WcfDiscovery(Self self, IManager engine) { _self = self; _engine = engine; var listener = new AnnouncementService(); listener.OnlineAnnouncementReceived += (sender, args) => handle_hello_message(args.EndpointDiscoveryMetadata); _mutex = new Object(); _serviceEndpoint = new UdpAnnouncementEndpoint(); _announcementService = new ServiceHost(listener); _announcementService.AddServiceEndpoint(_serviceEndpoint); _announcementCleint = new AnnouncementClient(new UdpAnnouncementEndpoint()); _counters = Context.Get<ICountersDb>().NewCounters(); }
public static void HostServiceAnnouncements() { // Create an AnnouncementService instance AnnouncementService announcementService = new AnnouncementService(); // Subscribe the announcement events announcementService.OnlineAnnouncementReceived += OnlineAnnouncementReceived; announcementService.OfflineAnnouncementReceived += OfflineAnnouncementReceived; // Create ServiceHost for the AnnouncementService using (ServiceHost announcementServiceHost = new ServiceHost(announcementService)) { // Listen for the announcements sent over UDP multicast announcementServiceHost.AddServiceEndpoint(new UdpAnnouncementEndpoint()); announcementServiceHost.Open(); Console.WriteLine("Listening for the announcements sent over UDP multicast network..."); while (Cancel == false) Thread.Sleep(1000000); } }
public static void Main(string[] args) { Console.WriteLine(" **** Announcement service ****"); AnnouncementService announcementService = new AnnouncementService(); announcementService.OnlineAnnouncementReceived += new EventHandler<AnnouncementEventArgs>(announcementService_OnlineAnnouncementReceived); announcementService.OfflineAnnouncementReceived += new EventHandler<AnnouncementEventArgs>(announcementService_OfflineAnnouncementReceived); // Search for the signing certificate in StoreLocation.LocalMachine, StoreName.My, using FindBySubjectDistinguishedName // Keep the default settings for client certificates (used to validate incoming messages): StoreLocation.LocalMachine, StoreName.My SigningCertificateSettings signingStoreSettings = new SigningCertificateSettings("CN=DiscoverySecureServiceCertificate"); ServiceHost host = new ServiceHost(announcementService); UdpAnnouncementEndpoint announcementEndpoint = new UdpSecureAnnouncementEndpoint( DiscoveryVersion.WSDiscovery11, signingStoreSettings); try { host.AddServiceEndpoint(announcementEndpoint); host.Open(); Console.WriteLine("\nPress enter to exit .."); Console.ReadLine(); host.Close(); } catch (CommunicationException e) { Console.WriteLine(e.Message); } catch (TimeoutException e) { Console.WriteLine(e.Message); } if (host.State != CommunicationState.Closed) { Console.WriteLine("Aborting the service..."); host.Abort(); } }
public static void Main() { AnnouncementService announcementService = new AnnouncementService(); // Subscribe to the announcement events announcementService.OnlineAnnouncementReceived += OnOnlineEvent; announcementService.OfflineAnnouncementReceived += OnOfflineEvent; // Host the AnnouncementService ServiceHost announcementServiceHost = new ServiceHost(announcementService); try { // Listen for the announcements sent over UDP multicast announcementServiceHost.AddServiceEndpoint(new UdpAnnouncementEndpoint()); announcementServiceHost.Open(); Console.WriteLine("Listening for service announcements."); Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate."); Console.ReadLine(); announcementServiceHost.Close(); } catch (CommunicationException e) { Console.WriteLine(e.Message); } catch (TimeoutException e) { Console.WriteLine(e.Message); } if (announcementServiceHost.State != CommunicationState.Closed) { Console.WriteLine("Aborting the service..."); announcementServiceHost.Abort(); } }
static void Main(string[] args) { AnnouncementService announcementService = new AnnouncementService(); announcementService.OnlineAnnouncementReceived += (sender, e) => { string contractTypes = string.Empty; Console.WriteLine("Receive Service Online Announcement."); Console.WriteLine("\tAddress: {0}", e.EndpointDiscoveryMetadata.Address.Uri); Console.WriteLine("\tContract: {0}", e.EndpointDiscoveryMetadata.ContractTypeNames[0]); }; announcementService.OfflineAnnouncementReceived += (sender, e) => { string contractTypes = string.Empty; Console.WriteLine("Receive Service Offline Announcement."); Console.WriteLine("\tAddress: {0}", e.EndpointDiscoveryMetadata.Address.Uri); Console.WriteLine("\tContract: {0}", e.EndpointDiscoveryMetadata.ContractTypeNames[0]); }; using (ServiceHost host = new ServiceHost(announcementService)) { host.Open(); Console.Read(); } }
private static void StartAnnouncementService() { var announcementService = new AnnouncementService(); announcementService.OnlineAnnouncementReceived += OnOnlineEvent; announcementService.OfflineAnnouncementReceived += OnOfflineEvent; AnnouncementServiceHost = new ServiceHost(announcementService); AnnouncementServiceHost.AddServiceEndpoint(new UdpAnnouncementEndpoint()); AnnouncementServiceHost.Open(); Console.WriteLine("Listening for service announcements."); Console.WriteLine(); }
private void Login() { try { Window1 LoginWin = new Window1(); LoginWin.ShowDialog(); username = LoginWin.GetName(); //InstanceContext ins = new InstanceContext(this); //proxy = new QQProxy(ins); //IAsyncResult iar = proxy.BeginJoin(username, new AsyncCallback(OnEndJoin), null); AnnouncementService announcementService = new AnnouncementService(); announcementService.OnlineAnnouncementReceived += (sender, e) => { string contractTypes = string.Empty; ShowTextBox.AppendText("Receive Service Online Announcement."); ShowTextBox.AppendText(string.Format("\tAddress: {0}", e.EndpointDiscoveryMetadata.Address.Uri)); ShowTextBox.AppendText(string.Format("\tContract: {0}", e.EndpointDiscoveryMetadata.ContractTypeNames[0])); }; announcementService.OfflineAnnouncementReceived += (sender, e) => { string contractTypes = string.Empty; ShowTextBox.AppendText("Receive Service Offline Announcement."); ShowTextBox.AppendText(string.Format("\tAddress: {0}", e.EndpointDiscoveryMetadata.Address.Uri)); ShowTextBox.AppendText(string.Format("\tContract: {0}", e.EndpointDiscoveryMetadata.ContractTypeNames[0])); }; using (ServiceHost host = new ServiceHost(announcementService)) { host.Open(); Console.Read(); } } catch (Exception e) { throw e; } }