/// <summary>
        /// Initializes the device. This method builds the colletion of internal device services, sets
        /// the devices transport address and adds DPWS required namespaces to the devices namespace collection.
        /// </summary>
        public static void Initialize(Binding binding, ProtocolVersion v)
        {
            m_binding = binding;

            string addr = binding.Transport.EndpointAddress.AbsoluteUri;
            int index = addr.LastIndexOf('/');
            m_address = "urn:uuid:" + addr.Substring(index+1);

            SubscriptionManager = new DpwsWseSubscriptionMgr(binding, v);

            if(v != null) 
            {            
                // Add disco services to udp service endpoints collection
                m_discoveryService = new DpwsDeviceDiscoService(v);
                m_discoGreeting = new DpwsDiscoGreeting(v);
                // Create a new udp service host and add the discovery endpoints
                WsUdpServiceHost.Instance.AddServiceEndpoint(m_discoveryService);
            }

            // Add metadata get service endpoint
            m_discoMexService = new DpwsDeviceMexService(v);
            m_hostedServices.Add(m_discoMexService);

            // Add direct probe service endpoint
            if(m_discoveryService != null) m_hostedServices.Add(m_discoveryService);

            // Create a new http service host and add hosted services endpoints
            m_httpServiceHost = new WsHttpServiceHost(m_binding, m_hostedServices);

            System.Ext.Console.Write("IP Address: " + WsNetworkServices.GetLocalIPV4Address());
        }
예제 #2
0
        /// <summary>
        /// Initializes the device. This method builds the colletion of internal device services, sets
        /// the devices transport address and adds DPWS required namespaces to the devices namespace collection.
        /// </summary>
        private static void Init()
        {
            // Add disco services to udp service endpoints collection
            m_discoveryService = new DpwsDeviceDiscoService();
            m_discoServiceEndpoints.Add(m_discoveryService);

            // Create a new udp service host and add the discovery endpoints
            m_udpServiceHost = new WsUdpServiceHost(m_discoServiceEndpoints);
            m_udpServiceHost.IgnoreRequestFromThisIP = m_ignoreRequestFromThisIP;

            // Add metadata get service endpoint
            m_discoMexService = new DpwsDeviceMexService();
            m_hostedServices.Add(m_discoMexService);

            // Add directd probe service endpoint
            m_hostedServices.Add(m_discoveryService);

            // Create a new http service host and add hosted services endpoints
            m_httpServiceHost = new WsHttpServiceHost(m_port, m_hostedServices);

            // Set the device endpoint address
            if (m_transportAddress == null)
            {
                m_transportAddress = "http://" + IPV4Address + ":" + m_port + "/" + m_address.Substring(9);
                System.Ext.Console.Write("");
                System.Ext.Console.Write("IP Address: " + IPV4Address);
                System.Ext.Console.Write("");
            }
        }