コード例 #1
0
        public static void Start(ServerBindingContext ctx)
        {
            if (m_isStarted)
            {
                throw new InvalidOperationException();
            }

            m_isStarted = true;

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

            // Start Udp service host
            WsUdpServiceHost.Instance.Start(ctx);
            System.Ext.Console.Write("Udp service host started...");

            // Send hello greeting
            if (m_discoGreeting != null)
            {
                m_discoGreeting.SendGreetingMessage(true);
            }

            // Start the event subscription manager
            m_eventQManager = new DpwsWseEventSinkQMgr();
            m_eventQManager.Start();
            System.Ext.Console.Write("Event subscription manager started...");
        }
コード例 #2
0
ファイル: MFSimpleDevice.cs プロジェクト: yisea123/NETMF-LPC
        //SimpleServiceClient client;

        public void Start()
        {
            // Initialize the binding
            string          guid    = "urn:uuid:18571766-87df-06e2-bb68-5136c48f483a";
            ProtocolVersion version = new ProtocolVersion10();

            Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig(guid, 8084)), version);

            // Set device information
            Device.ThisModel.Manufacturer    = "Microsoft Corporation";
            Device.ThisModel.ManufacturerUrl = "http://www.microsoft.com/";
            Device.ThisModel.ModelName       = "SimpleService Test Device";
            Device.ThisModel.ModelNumber     = "1.0";
            Device.ThisModel.ModelUrl        = "http://www.microsoft.com/";
            Device.ThisModel.PresentationUrl = "http://www.microsoft.com/";

            Device.ThisDevice.FriendlyName    = "SimpleService";
            Device.ThisDevice.FirmwareVersion = "alpha";
            Device.ThisDevice.SerialNumber    = "12345678";

            // Add a Host service type
            Device.Host = new SimpleDeviceHost();

            // Add Dpws hosted service(s) to the device
            Device.HostedServices.Add(new SimpleService(new SimpleServiceImplementation()));
            EventingService eventingService = new EventingService();

            Device.HostedServices.Add(eventingService);
            Device.HostedServices.Add(new AttachmentService(new AttachmentServiceImplementation()));

            // Add a Dpws client to this device. Uncomment to run a client and device
            //client = new SimpleServiceClient();

            // Set this device property if you want to ignore this clients request
            Device.IgnoreLocalClientRequest = false;

            // Turn console messages on
            Console.Verbose = true;

            System.Ext.Console.Write("Start DPWS device service with endpoint address: '" + Device.EndpointAddress + "'");

            // Start the device
            ServerBindingContext ctx = new ServerBindingContext(version);

            Device.Start(ctx);

            //TEST RESTART CAPABILITY
            //Thread.Sleep(3000);
            //Device.Stop();
            //Thread.Sleep(100);
            //Device.Start(ctx);

            // Events cause WsFaultExceptions if loopback messages are used.
            if (Device.IgnoreLocalClientRequest)
            {
                // Create and start EventSimulator
                EventSimulator eventSimulator = new EventSimulator(eventingService);
                eventSimulator.StartEventSimulator();
            }
        }
コード例 #3
0
ファイル: WsUdpServer.cs プロジェクト: leeholder/Netduino_SDK
 public void Start(ServerBindingContext ctx)
 {
     if (1 == Interlocked.Increment(ref m_refcount))
     {
         m_requestStop  = false;
         m_replyChannel = m_binding.CreateServerChannel(ctx);
         m_replyChannel.Open();
         m_thread = new Thread(new ThreadStart(this.Listen));
         m_thread.Start();
     }
 }
コード例 #4
0
        public void Start()
        {
            // Initialize the binding
            //Guid g = Guid.NewGuid();
            string guid = "urn:uuid:18571766-87df-06e2-bb68-5136c48f483f";

            ProtocolVersion version = new ProtocolVersion11();

            // ProtocolVersion10 can be used only if the corresponding HelloWorldClient_WCF application
            // uses a custom binding with Soap12WSAddressingAugust2004 text message encoding.
            //ProtocolVersion version = new ProtocolVersion10();

            Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig(guid, 8084)), version);

            // Set device information
            Device.ThisModel.Manufacturer    = "Microsoft Corporation";
            Device.ThisModel.ManufacturerUrl = "http://www.microsoft.com/";
            Device.ThisModel.ModelName       = "SimpleService Test Device";
            Device.ThisModel.ModelNumber     = "1.0";
            Device.ThisModel.ModelUrl        = "http://www.microsoft.com/";
            Device.ThisModel.PresentationUrl = "http://www.microsoft.com/";

            Device.ThisDevice.FriendlyName    = "HelloWorldService";
            Device.ThisDevice.FirmwareVersion = "alpha";
            Device.ThisDevice.SerialNumber    = "32345678";

            // Add a Host service type
            Device.Host = new HelloWCFService(version);

            // Add Dpws hosted service(s) to the device
            Device.HostedServices.Add(new IServiceHelloWCF(new ServiceHelloWCFImplementation()));

            // Set this device property if you want to ignore this clients request
            Device.IgnoreLocalClientRequest = false;

            // Turn console messages on
            Console.Verbose = true;

            System.Ext.Console.Write("Start DPWS device service with endpoint address: '" + Device.EndpointAddress + "'");

            ServerBindingContext ctx = new ServerBindingContext(version);

            // Start the device
            Device.Start(ctx);
        }
コード例 #5
0
        public MFTestResults DeviceTest_Start_Stop()
        {
            /// <summary>
            /// 1. Sets up the minimum framework to allow a Device object to start
            /// 2. Sleeps for 10 Seconds
            /// 3. Stops the Device
            /// </summary>
            ///

            bool testResult = true;

            try
            {
                ProtocolVersion ver = new ProtocolVersion10();
                Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig("urn:uuid:3cb0d1ba-cc3a-46ce-b416-212ac2419b51", 8084)), ver);
                //Device.EndpointAddress = "urn:uuid:3cb0d1ba-cc3a-46ce-b416-212ac2419b51";
                Device.ThisModel.Manufacturer    = "Microsoft";
                Device.ThisModel.ManufacturerUrl = "http://www.Microsoft.com/";
                Device.ThisModel.ModelName       = "MFDpwsDeviceTests Interop Test Device";
                Device.ThisModel.ModelNumber     = "1";
                Device.ThisModel.ModelUrl        = "http://www.Microsoft.com/";
                Device.ThisModel.PresentationUrl = "http://www.Microsoft.com/";

                Device.ThisDevice.FriendlyName    = "Test Device";
                Device.ThisDevice.FirmwareVersion = "alpha";
                Device.ThisDevice.SerialNumber    = "1";

                Device.Host = new TestDeviceHost("3cb0d1ba-cc3a-46ce-b416-212ac2419b51");

                Log.Comment("Starting Device...");
                ServerBindingContext ctx = new ServerBindingContext(ver);
                Device.Start(ctx);
                Log.Comment("Device started, sleeping for 10 seconds...");
                System.Threading.Thread.Sleep(10000);
                Log.Comment("Sleep completed.  Stopping Device...");
                Device.Stop();
                Log.Comment("Device stopped");
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return(testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
コード例 #6
0
ファイル: Master.cs プロジェクト: leeholder/Netduino_SDK
        public MFTestResults Start()
        {
            MFTestResults testResult = MFTestResults.Pass;

            try
            {
                //System.Ext.Console.Verbose = true;
                // Also start a local client on this device

                ProtocolVersion ver = new ProtocolVersion10();

                WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig("urn:uuid:3cb0d1ba-cc3a-46ce-b416-212ac2419b51", 8084));

                Device.Initialize(binding, ver);

                // Set device information
                //Device.EndpointAddress = "urn:uuid:3cb0d1ba-cc3a-46ce-b416-212ac2419b51";
                Device.ThisModel.Manufacturer    = "Microsoft Corporation";
                Device.ThisModel.ManufacturerUrl = "http://www.microsoft.com/";
                Device.ThisModel.ModelName       = "SimpleService Test Device";
                Device.ThisModel.ModelNumber     = "1.0";
                Device.ThisModel.ModelUrl        = "http://www.microsoft.com/";
                Device.ThisModel.PresentationUrl = "http://www.microsoft.com/";

                Device.ThisDevice.FriendlyName    = "SimpleService";
                Device.ThisDevice.FirmwareVersion = "alpha";
                Device.ThisDevice.SerialNumber    = "12345678";

                // Add a Host service type
                Device.Host = new SimpleDeviceHost();

                // Add DPWS hosted services to the device
                Device.HostedServices.Add(new SimpleService());
                Device.HostedServices.Add(new EventingService());
                Device.HostedServices.Add(new AttachmentService());

                Log.Comment("Start the Client");
                client = new SimpleServiceClient();
                client.IgnoreRequestFromThisIP = false;

                Thread.Sleep(500);

                // Set to true to ignore the local client's requests
                Device.IgnoreLocalClientRequest = false;

                // Start the device stack
                Log.Comment("Start the Device");
                ServerBindingContext ctx = new ServerBindingContext(ver);
                Device.Start(ctx);
                int timeOut = 600000;
                //  The Client should be done intergoating the service within 10 minutes
                if (!client.arHello.WaitOne(timeOut, false))
                {
                    Log.Comment("Client not done interogating the service for '" + timeOut + "' milliseconds");
                }
            }
            catch (Exception e)
            {
                Log.Comment("Unexpected Exception e: " + e.ToString());
            }
            finally
            {
                try
                {
                    Log.Comment("Stopping the service");
                    Device.Stop();
                }
                catch (Exception ex)
                {
                    Log.Comment("Caught : " + ex.Message);
                }
                Log.Comment("Waiting and verifying client received messages");

                //  Sleep for 15 seconds to let the client receive the bye events.
                client.arBye.WaitOne(15000, false);

                if (client != null)
                {
                    if (!client.m_receivedHelloEvent)
                    {
                        Log.Comment("Did not get HelloEvent.");
                        testResult = MFTestResults.Fail;
                    }
                    if (!client.m_getMex)
                    {
                        Log.Comment("Did not get GetMex.");
                        testResult = MFTestResults.Fail;
                    }
                    if (!client.m_twoWay)
                    {
                        Log.Comment("Did not get TwoWay.");
                        testResult = MFTestResults.Fail;
                    }
                    if (!client.m_receivedByeEvent)
                    {
                        Log.Comment("Did not get ByeEvent.");
                        testResult = MFTestResults.Fail;
                    }

                    client.Dispose();
                }
            }
            return(testResult);
        }