/// <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.DiscoMexService = 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());
        }
Example #2
0
        /// <summary>
        /// Method used to Start the stack transport services.
        /// </summary>
        /// <remarks>
        /// The Start Method initialises device specific services and calls the stack services to start
        /// the Http and UDP transport services. It also creates and starts an instance of the
        /// Event Queue manager service that manages event subscription expirations.
        /// </remarks>
        public static void Start()
        {
            isStarted = true;

            // Initialize the device collections
            System.Ext.Console.Write("");
            System.Ext.Console.Write("Initializing device.....");
            Init();

            // Start Udp service host
            m_udpServiceHost.Start();
            System.Ext.Console.Write("Udp service host started...");

            // Start Http service host
            m_httpServiceHost.Start();
            System.Ext.Console.Write("Http service host started...");

            // Start the event subscription manager
            m_eventQManager = new DpwsWseEventSinkQMgr();
            m_eventQManager.Start();
            System.Ext.Console.Write("Event subscription manager started...");

            // Send hello greeting
            DpwsDiscoGreeting.SendGreetingMessage(true);
        }
Example #3
0
        /// <summary>
        /// Static method used to stop stack transport services.
        /// </summary>
        /// <remarks>
        /// This method stops the underlying stack transport services and the devices event queue manager.
        /// </remarks>
        public static void Stop()
        {
            m_eventQManager.Stop();
            m_udpServiceHost.Stop();
            m_httpServiceHost.Stop();

            // Send bye
            DpwsDiscoGreeting.SendGreetingMessage(false);

            isStarted = false;
        }