Ejemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the Subscription manager class.
        /// </summary>
        /// <remarks>
        /// The device manages an instance of this class on behalf of the device. A device developer
        /// must use the static Device.SubScriptionMgr.FireEvent method to fire events from an event
        /// source.
        /// </remarks>
        public DpwsWseSubscriptionMgr(Binding binding, ProtocolVersion version)
        {
            m_binding = binding.Clone();
            m_version = version;

            m_reqChannel = binding.CreateClientChannel(new ClientBindingContext(version));
        }
Ejemplo n.º 2
0
        public SimpleServiceClientProxy(Binding binding, ProtocolVersion version) : 
                base(binding, version)
        {

            // Set client endpoint address
            m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a http service host.
 /// </summary>
 /// <param name="port">An integer containing the port number this host will listen on.</param>
 /// <param name="serviceEndpoints">A collection of service endpoints this transport service can dispatch to.</param>
 public WsHttpServiceHost(_Bind.Binding binding, WsServiceEndpoints serviceEndpoints)
 {
     m_threadManager    = new WsThreadManager(5, "Http");            
     m_binding          = binding;
     m_serviceEndpoints = serviceEndpoints;
     m_isStarted        = false;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a http service host.
 /// </summary>
 /// <param name="port">An integer containing the port number this host will listen on.</param>
 /// <param name="serviceEndpoints">A collection of service endpoints this transport service can dispatch to.</param>
 public WsHttpServiceHost(_Bind.Binding binding, WsServiceEndpoints serviceEndpoints)
 {
     m_threadManager    = new WsThreadManager(5, "Http");
     m_binding          = binding;
     m_serviceEndpoints = serviceEndpoints;
     m_isStarted        = false;
 }
        public EventingServiceClientProxy(Binding binding, ProtocolVersion version, IEventingServiceCallback callbackHandler) : 
                base(binding, version)
        {
            // Set the client callback implementation property
            m_eventHandler = callbackHandler;

            // Set client endpoint address
            m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));

            // Add client callback operations and event source types
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "SimpleEvent"));
            EventSources.Add(new DpwsServiceType("SimpleEvent", "http://schemas.example.org/EventingService"));
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "IntegerEvent"));
            EventSources.Add(new DpwsServiceType("IntegerEvent", "http://schemas.example.org/EventingService"));
        }
        public EventingServiceClientProxy(Binding binding, ProtocolVersion version, IEventingServiceCallback callbackHandler) : 
                base(binding, version)
        {
            // Set the client callback implementation property
            m_eventHandler = callbackHandler;

            // Set client endpoint address
            m_requestChannel = m_localBinding.CreateClientChannel(new ClientBindingContext(m_version));

            // Add client callback operations and event source types
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "SimpleEvent"));
            EventSources.Add(new DpwsServiceType("SimpleEvent", "http://schemas.example.org/EventingService"));
            ServiceOperations.Add(new WsServiceOperation("http://schemas.example.org/EventingService", "IntegerEvent"));
            EventSources.Add(new DpwsServiceType("IntegerEvent", "http://schemas.example.org/EventingService"));

            // Add eventing SubscriptionEnd ServiceOperations. By default Subscription End call back to this client
            ServiceOperations.Add(new WsServiceOperation(WsWellKnownUri.WseNamespaceUri, "SubscriptionEnd"));

            this.StartEventListeners();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates an instance of a DpwsClient class with a specified eventing callback port number.
        /// </summary>
        public DpwsClient(Binding localBinding, ProtocolVersion v)
        {
            m_threadLock               = new object();
            m_eventClient              = new DpwsEventingClient(v);
            m_mexClient                = new DpwsMexClient(v);
            m_eventCallbacks           = new WsServiceOperations();
            m_callbackServiceEndpoints = new WsServiceEndpoints();
            m_blockingCall             = true;
            m_ignoreRequestFromThisIP  = true;
            m_localBinding             = localBinding;
            m_version                  = v;

            m_discoClient = new DpwsDiscoveryClient(this, v);

            // Add the Hello and Bye discovery disco services
            ClientDiscoveryService = new DpwsDiscoClientService(this, v);

            // Start a Udp discovery service host
            WsUdpServiceHost.Instance.AddServiceEndpoint(ClientDiscoveryService);
            WsUdpServiceHost.Instance.IgnoreRequestFromThisIP = m_ignoreRequestFromThisIP;
            WsUdpServiceHost.Instance.MaxThreadCount = 5;
            WsUdpServiceHost.Instance.Start(new ServerBindingContext(v));
        }
        /// <summary>
        /// Creates an instance of a DpwsClient class with a specified eventing callback port number.
        /// </summary>
        public DpwsClient(Binding localBinding, ProtocolVersion v)
        {
            m_threadLock               = new object();
            m_eventClient              = new DpwsEventingClient(v);
            m_mexClient                = new DpwsMexClient(v);
            m_eventCallbacks           = new WsServiceOperations();
            m_callbackServiceEndpoints = new WsServiceEndpoints();
            m_blockingCall             = true;
            m_ignoreRequestFromThisIP  = true;
            m_localBinding             = localBinding;
            m_version                  = v;

            m_discoClient = new DpwsDiscoveryClient(this, v);

            // Add the Hello and Bye discovery disco services
            ClientDiscoveryService = new DpwsDiscoClientService(this, v);

            // Start a Udp discovery service host
            WsUdpServiceHost.Instance.AddServiceEndpoint(ClientDiscoveryService);
            WsUdpServiceHost.Instance.IgnoreRequestFromThisIP = m_ignoreRequestFromThisIP;
            WsUdpServiceHost.Instance.MaxThreadCount = 5;
            WsUdpServiceHost.Instance.Start(new ServerBindingContext(v));

            // Add eventing SubscriptionEnd ServiceOperations. By default Subscription End call back
            // to this client
            ServiceOperations.Add(new WsServiceOperation(WsWellKnownUri.WseNamespaceUri, "SubscriptionEnd"));

            // Add callbacks implemented by this client
            m_callbackServiceEndpoints.Add(this);

            // Start the Http service host
            m_httpServiceHost = new WsHttpServiceHost(m_localBinding, m_callbackServiceEndpoints);
            m_httpServiceHost.MaxThreadCount = m_callbackServiceEndpoints.Count;
            m_httpServiceHost.Start(new ServerBindingContext(v));
            System.Ext.Console.Write("Http service host started...");
        }
        /// <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());
        }
Ejemplo n.º 10
0
 internal ReplyChannel( Binding binding, BindingContext context )
 {
     this.m_binding = binding;
     this.m_context = context;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates an instance of the Subscription manager class.
 /// </summary>
 /// <remarks>
 /// The device manages an instance of this class on behalf of the device. A device developer
 /// must use the static Device.SubScriptionMgr.FireEvent method to fire events from an event
 /// source.
 /// </remarks>
 public DpwsWseSubscriptionMgr(Binding binding, ProtocolVersion version)
 {
     m_version = version;
     m_persistEventConnections = false;
     m_evtChannelLookup = new Hashtable();
 }