예제 #1
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);
            }
        }
예제 #2
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;
 }
예제 #3
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);
        }