コード例 #1
0
            /// <summary>
            /// Called when [online annoncement].
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The <see cref="System.ServiceModel.Discovery.AnnouncementEventArgs"/> instance containing the event data.</param>
            private void OnOnlineAnnoncement(object sender, AnnouncementEventArgs e)
            {
                var address = e.EndpointDiscoveryMetadata.Address;

                Uri uri = address.Uri;

                if (uri.AbsoluteUri.EndsWith("mex"))
                {
                    return;
                }
                if (uri.Scheme == CHANNEL_TYPE_NAMEPIPE)
                {
                    AddProxies(() => new NetNamedPipeBinding(), address);
                }
                else if (uri.Scheme != CHANNEL_TYPE_NAMEPIPE)
                {
                    AddProxies(() => new NetTcpBinding(), address);
                }

                try
                {
                    Ping();
                }

                #region Exception Handling

                catch (Exception ex)
                {
                    TraceSourceMonitorHelper.Warn("MonitorWcfDiscoveryProxy: ping faild, {0}", ex);
                }

                #endregion Exception Handling
            }
コード例 #2
0
ファイル: DevicesList.cs プロジェクト: kudrinyaroslav/ON-0110
        void OnOnlineEvent(object sender, AnnouncementEventArgs e)
        {
            ListViewItem item = new ListViewItem(e.EndpointDiscoveryMetadata.Address.ToString());

            lvDevices.Items.Add(item);

            Console.WriteLine("Received an online announcement from {0}", e.EndpointDiscoveryMetadata.Address);
        }
コード例 #3
0
 void UnregisterEndpoint(object obj, AnnouncementEventArgs e)
 {
     if (!PushQueueItem(e.MessageSequence))
     {
         return;
     }
     endpoints.Remove(e.EndpointDiscoveryMetadata);
 }
コード例 #4
0
        private async void OnOnlineEvent(object sender, AnnouncementEventArgs e)
        {
            var state = (_serverAppService as ICommunicationObject).State;

            if (state != CommunicationState.Opened && state != CommunicationState.Opening)
            {
                await Connect(e.EndpointDiscoveryMetadata.Address.Uri.ToString()).ConfigureAwait(false);
            }
        }
コード例 #5
0
ファイル: ServiceResolver.cs プロジェクト: llenroc/Rain
 static void OnOnlineAnnouncementReceived(object sender, AnnouncementEventArgs e)
 {
     foreach (var wContractType in e.EndpointDiscoveryMetadata.ContractTypeNames)
     {
         if (_discoverers.TryGetValue(wContractType.Name, out var resolver))
         {
             resolver.OnServiceOnlineAnnouncementReceived(e.EndpointDiscoveryMetadata);
         }
     }
 }
コード例 #6
0
ファイル: AnnouncementSink.cs プロジェクト: SinaC/TetriNET
 void OnHello(object sender, AnnouncementEventArgs args)
 {
     foreach (XmlQualifiedName contract in args.EndpointDiscoveryMetadata.ContractTypeNames)
     {
         if (contract.Name == typeof(T).Name && contract.Namespace == Namespace)
         {
             PublishNotificationEvent(OnHelloEvent, args.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri);
             Dictionary[args.EndpointDiscoveryMetadata.Address] = args.EndpointDiscoveryMetadata.Scopes;
         }
     }
 }
コード例 #7
0
    void RegisterEndpoint(object obj, AnnouncementEventArgs e)
    {
        if (!PushQueueItem(e.MessageSequence))
        {
            return;
        }
        var edm = e.EndpointDiscoveryMetadata;

        Console.WriteLine("New endpoint: {0} {1} {2}", edm.Address, edm.ContractTypeNames.Count, edm.Scopes.Count);
        endpoints.Add(e.EndpointDiscoveryMetadata);
    }
コード例 #8
0
        private static void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            Console.WriteLine("Bye!");
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            if (metadata != null && metadata.ListenUris.Count > 0 && metadata.ListenUris[0].Equals(endpointAddress.Uri))
            {
                Console.WriteLine("Service said goodbye!!");
                endpointAddress = null;
                hostedEndPoint  = null;
            }
        }
コード例 #9
0
            /// <summary>
            /// Called when [offline annoncement].
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The <see cref="System.ServiceModel.Discovery.AnnouncementEventArgs"/> instance containing the event data.</param>
            private void OnOfflineAnnoncement(object sender, AnnouncementEventArgs e)
            {
                var address = e.EndpointDiscoveryMetadata.Address;

                Uri uri = address.Uri;

                if (uri.AbsoluteUri.EndsWith("mex"))
                {
                    return;
                }

                Cleanup(uri.AbsolutePath);
            }
コード例 #10
0
        private static void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            if (metadata.ListenUris.Count > 0 && metadata.ListenUris[0].Equals(endpointAddress.Uri))
            {
                Console.WriteLine("Service said goodbye!!");
                endpointAddress             = null;
                accelerationServiceEndPoint = null;
                deviceInfoServiceEndPoint   = null;
                dataLoggingServiceEndPoint  = null;
            }
        }
コード例 #11
0
ファイル: AnnouncementSink.cs プロジェクト: SinaC/TetriNET
        void OnBye(object sender, AnnouncementEventArgs args)
        {
            foreach (XmlQualifiedName contract in args.EndpointDiscoveryMetadata.ContractTypeNames)
            {
                if (contract.Name == typeof(T).Name && contract.Namespace == Namespace)
                {
                    PublishNotificationEvent(OnByeEvent, args.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri);

                    Debug.Assert(Dictionary.ContainsKey(args.EndpointDiscoveryMetadata.Address));

                    Dictionary.Remove(args.EndpointDiscoveryMetadata.Address);
                }
            }
        }
コード例 #12
0
 protected void OnHello(object sender, AnnouncementEventArgs args)
 {
     if (Dictionary.ContainsKey(args.EndpointDiscoveryMetadata.Address))
     {
         return;
     }
     foreach (XmlQualifiedName contract in args.EndpointDiscoveryMetadata.ContractTypeNames)
     {
         if (contract.Name == typeof(T).Name && contract.Namespace == Namespace)
         {
             Dictionary[args.EndpointDiscoveryMetadata.Address] = args.EndpointDiscoveryMetadata.Scopes.ToArray();
             PublishAvailabilityEvent(OnlineAnnouncementReceived, args.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri, args.EndpointDiscoveryMetadata.Scopes.ToArray());
         }
     }
 }
コード例 #13
0
        private void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            FindCriteria criteria = new FindCriteria(typeof(T));

            if (criteria.IsMatch(metadata))
            {
                // 指定类型的服务下线
                if (cache.Contains(metadata.Address.Uri))
                {
                    cache.Remove(metadata);
                    Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Announcement endpoint offline : {0} - {1}", metadata.GetSpecifiedName(), metadata.Address.Uri));
                }
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: teco-kit/dpwsGW
        private static void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            Console.WriteLine("Bye!");
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            if (metadata != null && metadata.ListenUris.Count > 0)
            {
                foreach (edu.teco.DPWS.Device device in knownDevices)
                {
                    if (device.EndpointAddress.Uri.Equals(metadata.ListenUris[0]))
                    {
                        knownDevices.Remove(device);
                        Console.WriteLine("Device removed {0}:{1} at {2}", device.GetDeviceType().Namespace, device.GetDeviceType().Name, metadata.ListenUris[0]);
                        break;
                    }
                }
            }
        }
コード例 #15
0
        private static void OnOnlineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            // Check if service is SSimpDeviceType which is the Host service used
            foreach (System.Xml.XmlQualifiedName type in metadata.ContractTypeNames)
            {
                if (type.Equals(new System.Xml.XmlQualifiedName("AccelerationDeviceType", "http://www.teco.edu/AccelerationService")))
                {
                    Console.WriteLine("New service found: !!");
                    AnnouncementFound = true;

                    endpointAddress = new EndpointAddress(metadata.ListenUris[0]);
                    GetServiceEndPoints(endpointAddress);
                    Console.WriteLine("Service can now be invoked");
                }
            }
        }
コード例 #16
0
        protected void OnBye(object sender, AnnouncementEventArgs args)
        {
            if (Dictionary.ContainsKey(args.EndpointDiscoveryMetadata.Address))
            {
                Dictionary.Remove(args.EndpointDiscoveryMetadata.Address);
            }
            foreach (XmlQualifiedName contract in args.EndpointDiscoveryMetadata.ContractTypeNames)
            {
                if (contract.Name == typeof(T).Name && contract.Namespace == Namespace)
                {
                    PublishAvailabilityEvent(OfflineAnnouncementReceived, args.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri, args.EndpointDiscoveryMetadata.Scopes.ToArray());

                    if (Dictionary.ContainsKey(args.EndpointDiscoveryMetadata.Address) == false)
                    {
                        Trace.WriteLine("Received 'bye' announcement that did not have matching 'hello' first from address " + args.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri);
                    }
                }
            }
        }
コード例 #17
0
ファイル: DevicesList.cs プロジェクト: kudrinyaroslav/ON-0110
        void OnOfflineEvent(object sender, AnnouncementEventArgs e)
        {
            string addr = e.EndpointDiscoveryMetadata.Address.ToString();
            List <ListViewItem> items = new List <ListViewItem>();

            foreach (ListViewItem item in lvDevices.Items)
            {
                if (item.Text == addr)
                {
                    items.Add(item);
                }
            }

            foreach (ListViewItem item in items)
            {
                lvDevices.Items.Remove(item);
            }

            Console.WriteLine("Received an offline announcement from {0}", e.EndpointDiscoveryMetadata.Address);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: teco-kit/dpwsGW
        private static void OnOnlineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            Console.WriteLine("Hello!");
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            // Check if service is SSimpDeviceType which is the Host service used
            foreach (System.Xml.XmlQualifiedName type in metadata.ContractTypeNames)
            {
                foreach (System.Xml.XmlQualifiedName name in deviceTypes.Keys)
                {
                    if (type.Equals(name))
                    {
                        Console.WriteLine("New device found: {0}:{1} at {2}", name.Namespace, name.Name, metadata.ListenUris[0]);
                        edu.teco.DPWS.Device device = (edu.teco.DPWS.Device)Activator.CreateInstance(deviceTypes[name]);
                        device.EndpointAddress = new EndpointAddress(metadata.ListenUris[0]);
                        GetMetaData(device);
                        device.Init();
                        knownDevices.Add(device);
                        Console.WriteLine("Service can now be invoked");
                        break;
                    }
                }
            }
        }
コード例 #19
0
ファイル: Client.cs プロジェクト: yongzhao1/dotnet-samples
 static void OnOfflineEvent(object sender, AnnouncementEventArgs e)
 {
     Console.WriteLine();
     Console.WriteLine("Received an offline announcement from {0}:", e.EndpointDiscoveryMetadata.Address);
     PrintEndpointDiscoveryMetadata(e.EndpointDiscoveryMetadata);
 }
コード例 #20
0
 static void OnlineAnnouncementReceived(object sender, AnnouncementEventArgs e)
 {
     CarRentalEndpoint = e.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri;
 }
コード例 #21
0
 private void OnOnlineEvent(object sender, AnnouncementEventArgs e)
 {
     _availableEndpoints.Add(e.EndpointDiscoveryMetadata.Address);
     AvailableEndpointsChanged?.Invoke(this, new EventArgs());
 }
コード例 #22
0
        private static void AnnouncementSrvOfflineAnnouncementReceived(object sender, AnnouncementEventArgs args)
        {
            var uris = args?.EndpointDiscoveryMetadata?.ListenUris;

            if (uris == null)
            {
                return;
            }
            foreach (var uri in uris)
            {
                if (uri != null)
                {
                    RemoveDevice(uri.ToString());
                }
            }
        }
コード例 #23
0
 private static void Announcement_srv_OnlineAnnouncementReceived(object sender, AnnouncementEventArgs args)
 {
     CheckDevice(args.EndpointDiscoveryMetadata);
 }
コード例 #24
0
        void IServiceBusAnnouncements.OnHello(Uri address, string contractName, string contractNamespace, Uri[] scopes)
        {
            AnnouncementEventArgs args = DiscoveryHelper.CreateAnnouncementArgs(address, contractName, contractNamespace, scopes);

            OnHello(this, args);
        }
コード例 #25
0
 private async void OnOfflineEvent(object sender, AnnouncementEventArgs e)
 {
     SetState(ClientState.Initializing);
     await Connect(e.EndpointDiscoveryMetadata.Address.Uri.ToString()).ConfigureAwait(false);
 }
コード例 #26
0
ファイル: Program.cs プロジェクト: liuhonglei/WCFStudy
 private static void AnnouncementService_OnlineAnnouncementReceived(object sender, AnnouncementEventArgs e)
 {
     Console.WriteLine("online");
     Console.WriteLine(e.EndpointDiscoveryMetadata.Address.Uri);
     Console.WriteLine(e.EndpointDiscoveryMetadata.ContractTypeNames[0].Name);
 }
コード例 #27
0
 static void OfflineAnnouncementReceived(object sender, AnnouncementEventArgs e)
 {
     CarRentalEndpoint = "";
 }
コード例 #28
0
 void m_DiscoveryClient_ProxyAvailable(object sender, AnnouncementEventArgs e)
 {
     DiscoveryManaged(e.EndpointDiscoveryMetadata.Address.Uri.AbsoluteUri);
 }
コード例 #29
0
ファイル: Program.cs プロジェクト: yongzhao1/dotnet-samples
 static void announcementService_OnlineAnnouncementReceived(object sender, AnnouncementEventArgs e)
 {
     Console.WriteLine("Received Online Announcement from {0}", e.EndpointDiscoveryMetadata.Address);
 }