Exemple #1
0
        /// <summary>
        /// Creates and instance of the DpwsDiscoveryClient class.
        /// </summary>
        internal DpwsDiscoveryClient(DpwsClient parent)
        {
            m_parent = parent;

            DiscoveryEP = new IPEndPoint(DiscoveryAddress, DiscoveryPort);

            m_random = new Random();
        }
        /// <summary>
        /// Creates and instance of the DpwsDiscoveryClient class.
        /// </summary>
        internal DpwsDiscoveryClient(DpwsClient parent)
        {
            m_parent = parent;

            DiscoveryEP = new IPEndPoint(DiscoveryAddress, DiscoveryPort);

            m_random = new Random();
        }
 /// <summary>
 /// Creates and instance of the DpwsDiscoveryClient class.
 /// </summary>
 internal DpwsDiscoveryClient(DpwsClient parent, ProtocolVersion v)
 {
     // Discovery Port defined by http://www.iana.org/assignments/port-numbers as Web Services for Devices
     m_discoResponsePort = 5357;
     m_receiveTimeout    = 5000;
     m_version           = v;
     m_parent            = parent;
     m_random            = new Random();
 }
 /// <summary>
 /// Creates and instance of the DpwsDiscoveryClient class.
 /// </summary>
 internal DpwsDiscoveryClient(DpwsClient parent, ProtocolVersion v)
 {
     // Arbitrary available port value for default ws-discovery response port
     m_discoResponsePort = 15357;
     m_receiveTimeout    = 5000;
     m_version = v;
     m_parent = parent;
     m_random = new Random();
 }
        public DpwsDiscoClientService(DpwsClient client)
        {
            m_client = client;

            // Add discovery Hello ServiceOperations
            m_discoCallbacks = new WsServiceOperations();
            m_discoCallbacks.Add(new WsServiceOperation(WsWellKnownUri.WsdNamespaceUri, "Hello"));
            m_discoCallbacks.Add(new WsServiceOperation(WsWellKnownUri.WsdNamespaceUri, "Bye"));
        }
 /// <summary>
 /// Creates and instance of the DpwsDiscoveryClient class.
 /// </summary>
 internal DpwsDiscoveryClient(DpwsClient parent, ProtocolVersion v)
 {
     // Discovery Port defined by http://www.iana.org/assignments/port-numbers as Web Services for Devices
     m_discoResponsePort = 5357;
     m_receiveTimeout    = 5000;
     m_version = v;
     m_parent = parent;
     m_random = new Random();
 }
Exemple #7
0
        public DpwsDiscoClientService(DpwsClient client)
        {
            m_client = client;

            // Add discovery Hello ServiceOperations
            m_discoCallbacks = new WsServiceOperations();
            m_discoCallbacks.Add(new WsServiceOperation(WsWellKnownUri.WsdNamespaceUri, "Hello"));
            m_discoCallbacks.Add(new WsServiceOperation(WsWellKnownUri.WsdNamespaceUri, "Bye"));
        }
Exemple #8
0
 /// <summary>
 /// Creates and instance of the DpwsDiscoveryClient class.
 /// </summary>
 internal DpwsDiscoveryClient(DpwsClient parent, ProtocolVersion v)
 {
     // Arbitrary available port value for default ws-discovery response port
     m_discoResponsePort = 15357;
     m_receiveTimeout    = 5000;
     m_version           = v;
     m_parent            = parent;
     m_random            = new Random();
 }
        //--//

        public DpwsDiscoClientService(DpwsClient client, ProtocolVersion version)
        {
            m_client     = client;
            m_threadLock = new object();
            m_version    = version;

            m_messageCheck = new WsMessageCheck();

            // Add discovery Hello ServiceOperations
            m_discoCallbacks = new WsServiceOperations();
            m_discoCallbacks.Add(new WsServiceOperation(m_version.DiscoveryNamespace, "Hello"));
            m_discoCallbacks.Add(new WsServiceOperation(m_version.DiscoveryNamespace, "Bye"));
        }
        //--//

        public DpwsDiscoClientService(DpwsClient client, ProtocolVersion version)
        {
            m_client = client;
            m_threadLock = new object();
            m_version = version;

            m_messageCheck = new WsMessageCheck();

            // Add discovery Hello ServiceOperations
            m_discoCallbacks = new WsServiceOperations();
            m_discoCallbacks.Add(new WsServiceOperation(m_version.DiscoveryNamespace, "Hello"));
            m_discoCallbacks.Add(new WsServiceOperation(m_version.DiscoveryNamespace, "Bye"));
        }
Exemple #11
0
        public static void Main()
        {
            using (DpwsClient client = new DpwsClient()) // initializing
            {
                // Set this client property if you want to ignore this devices request
                client.IgnoreRequestFromThisIP = false;
                client.HelloEvent += new HelloEventHandler(client_HelloEvent);
                client.ByeEvent   += new ByeEventHandler(client_ByeEvent);

                // Keep the client alive
                Thread.Sleep(Timeout.Infinite);
            }
        }
Exemple #12
0
 /// <summary>
 /// Creates an instance of the eventing client.
 /// </summary>
 /// <param name="client">The DpwsClient instance that will receive events.</param>
 public DiscoClient(DpwsClient client)
 {
     m_dpwsClient = client;
 }
Exemple #13
0
        public MFTestResults ClientTest_DpwsClient_Properties()
        {
            /// <summary>
            /// 1. Verifies each of the proerties of a DPWSClient object
            /// 2. Sets and re-verifies for simple properties, checks input checking
            /// on properties that currently support it.
            /// </summary>
            ///
            ProtocolVersion v          = new ProtocolVersion10();
            bool            testResult = true;
            int             port       = 50002;
            DpwsClient      testClient = new DpwsClient(new WS2007HttpBinding(new HttpTransportBindingConfig("urn:uuid:" + Guid.NewGuid().ToString(), port)), v);

            try
            {
                Log.Comment("EndpointAddress");
                if (testClient.EndpointAddress != null)
                {
                    if (testClient.EndpointAddress.GetType() != Type.GetType("System.String"))
                    {
                        throw new Exception("EndpointAddress wrong type");
                    }
                }

                String uri = v.AnonymousUri;
                testClient.EndpointAddress = uri;
                if (testClient.EndpointAddress.GetType() != Type.GetType("System.String"))
                {
                    throw new Exception("EndpointAddress wrong type after set");
                }

                if (testClient.EndpointAddress != uri)
                {
                    throw new Exception("EndpointAddress bad data");
                }

                try
                {
                    testClient.EndpointAddress = " test";
                    throw new Exception("EndpointAddress failed to prevent bad data input");
                }
                catch (System.ArgumentException) { }

                Log.Comment("IgnoreRequestFromThisIP");
                if (testClient.IgnoreRequestFromThisIP.GetType() !=
                    Type.GetType("System.Boolean"))
                {
                    throw new Exception("IgnoreRequestFromThisIP wrong type");
                }

                testClient.IgnoreRequestFromThisIP = true;

                if (!testClient.IgnoreRequestFromThisIP)
                {
                    throw new Exception("IgnoreRequestFromThisIP wrong data after set");
                }

                Log.Comment("ServiceOperations");
                if (testClient.ServiceOperations != null)
                {
                    if (testClient.ServiceOperations.GetType() !=
                        Type.GetType("Ws.Services.WsServiceOperations"))
                    {
                        throw new Exception("ServiceOperations wrong type");
                    }
                }

                Log.Comment("TransportAddress");
                if (testClient.TransportAddress != null)
                {
                    if (testClient.TransportAddress.GetType() != Type.GetType("System.String"))
                    {
                        throw new Exception("TransportAddress wrong type");
                    }
                }
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            finally
            {
                if (testClient != null)
                {
                    testClient.Dispose();
                }
            }

            return(testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }