public void DiscoveryModeConfigurationTest()
        {
            RunTest(
                () =>
            {
                DiscoveryMode mode = GetDiscoveryMode();
                Assert(mode == DiscoveryMode.Discoverable, "Discovery invalid mode discovery mode returned.", "Check current DiscoveryMode");
                // Set NonDiscoverable
                SetDiscoveryMode(DiscoveryMode.NonDiscoverable);

                mode = GetDiscoveryMode();
                Assert(mode == DiscoveryMode.NonDiscoverable, "Discovery invalid mode discovery mode returned.", "Check current DiscoveryMode");

                //probe device while it is non-discoverable
                InvalidProbeDeviceStep(true, null);

                //reboot and verify no bye or hello
                ReceiveByeOrHelloMessage(
                    true,
                    true,
                    () => { Reboot(); },
                    (p) =>
                {
                    if (p != null)
                    {
                        string reason = string.Format("NVT sent {0} while NVT is NonDiscoverable",
                                                      p.Object is WSD.HelloType ? "Hello" : "Bye");
                        throw new AssertException(reason);
                    }
                });
                SetDiscoveryMode(DiscoveryMode.Discoverable);
            });
        }
Exemplo n.º 2
0
        protected DiscoveryMode EndGetDiscoveryMode(IAsyncResult result)
        {
            DiscoveryMode mode = Client.EndGetDiscoveryMode(result);

            StepPassed();
            return(mode);
        }
Exemplo n.º 3
0
        void DiscoveryTestAsync2()
        {
            try
            {
                BeginTest();

                DiscoveryMode backup = BeginEndGetDiscoveryMode();

                // Set Discoverable

                BeginEndSetDiscoveryMode(DiscoveryMode.Discoverable);

                DiscoveryMode afterSet = BeginEndGetDiscoveryMode();

                Assert(afterSet == DiscoveryMode.Discoverable);

                BeginEndSetDiscoveryMode(DiscoveryMode.NonDiscoverable);

                afterSet = BeginEndGetDiscoveryMode();

                Assert(afterSet == DiscoveryMode.NonDiscoverable);

                BeginEndSetDiscoveryMode(backup);

                EndTest();
            }
            catch (StopEventException)
            {
            }
            catch (Exception ex)
            {
                StepFailed(ex);
                TestFailed(ex);
            }
        }
Exemplo n.º 4
0
        protected DiscoveryMode GetDiscoveryMode()
        {
            DiscoveryMode mode = DiscoveryMode.Discoverable;

            RunStep(() => { mode = Client.GetDiscoveryMode(); }, "Get Discovery Mode");
            return(mode);
        }
Exemplo n.º 5
0
        private void btnSetDiscoveryMode_Click(object sender, EventArgs e)
        {
            try
            {
                DiscoveryMode mode = (DiscoveryMode)comboBoxDiscoveryMode.SelectedValue;

                DeviceClient service = GetService();

                if (cbTrace.Checked)
                {
                    if (cbLowLevelTrace.Checked)
                    {
                        System.ServiceModel.Channels.CustomBinding cb    = (System.ServiceModel.Channels.CustomBinding)service.Endpoint.Binding;
                        CustomTextMessageBindingElement            ctmbe = (CustomTextMessageBindingElement)cb.Elements[0];

                        string value = "Discoverrable";
                        string path  = "/s:Envelope/s:Body/onvif:SetDiscoveryMode/onvif:DiscoveryMode";
                        Dictionary <string, string> namespaces = new Dictionary <string, string>();
                        namespaces.Add("s", "http://www.w3.org/2003/05/soap-envelope");
                        namespaces.Add("onvif", "http://www.onvif.org/ver10/device/wsdl");
                        ctmbe.AddBreakingBehaviour(new BreakingBehaviour(path, value, namespaces));
                    }
                }

                service.SetDiscoveryMode(mode);
                ShowStatusMessage("Done");
                service.Close();
            }
            catch (Exception ex)
            {
                ShowStatusMessage("Operation failed");
                TraceException(ex);
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        protected DiscoveryMode GetDiscoveryMode()
        {
            BeginStep("GetDiscoveryMode");
            DiscoveryMode mode = Client.GetDiscoveryMode();

            StepPassed();
            return(mode);
        }
Exemplo n.º 7
0
        protected void BeginEndSetDiscoveryMode(DiscoveryMode mode)
        {
            BeginStep("SetDiscoveryMode");
            IAsyncResult result = Client.BeginSetDiscoveryMode(mode, null, null);

            WaitForSomething(result);
            Client.EndSetDiscoveryMode(result);
            StepPassed();
        }
Exemplo n.º 8
0
        public override void SetDiscoveryMode(DiscoveryMode DiscoveryMode)
        {
            ConfStorageLoad();
            EventServerLoad();

            ConfStorage.DiscoveryMode = DiscoveryMode;

            EventServerSave();
            ConfStorageSave();
        }
Exemplo n.º 9
0
        protected DiscoveryMode BeginEndGetDiscoveryMode()
        {
            BeginStep("GetDiscoveryMode");
            IAsyncResult result = Client.BeginGetDiscoveryMode(null, null);

            WaitForSomething(result);
            DiscoveryMode mode = Client.EndGetDiscoveryMode(result);

            StepPassed();
            return(mode);
        }
Exemplo n.º 10
0
        public IServiceDiscoveryRequest CreateServiceDiscoveryRequest(
            Maybe <IConsumedServiceReference> consumedService,
            DiscoveryMode mode,
            IContextLinkageOptions contextLinkageOptions)
        {
            var obj = ServiceDiscoveryRequest.Rent();

            obj.ConsumedService       = consumedService;
            obj.DiscoveryMode         = mode;
            obj.ContextLinkageOptions = contextLinkageOptions;
            return(obj);
        }
Exemplo n.º 11
0
        public IMethodDiscoveryRequest CreateMethodDiscoveryRequest(
            Maybe <string> inputMessageId,
            Maybe <string> outputMessageId,
            Maybe <IConsumedMethodReference> method,
            DiscoveryMode discoveryMode)
        {
            var obj = MethodDiscoveryRequest.Rent();

            obj.InputMessageId  = inputMessageId;
            obj.OutputMessageId = outputMessageId;
            obj.ConsumedMethod  = method;
            obj.DiscoveryMode   = discoveryMode;
            return(obj);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Console.Write("Creating service client...");
            OnVifDeviceClient client = new OnVifDeviceClient("WSHttpBinding_IOnVifDevice");

            Console.WriteLine("Ok!");

            Console.Write("Calling Operation 'SetDiscoveryMode()' ....");
            client.SetDiscoveryMode(DiscoveryMode.Discoverable);
            Console.WriteLine("Ok!");

            Console.Write("Calling Operation 'GetDiscoveryMode()' ....");
            DiscoveryMode mode = client.GetDiscoveryMode();

            Console.WriteLine("Ok!. Result: {0}", mode);
        }
 public void RevertChanges()
 {
     this.current.useHostFromDhcp = this.origin.useHostFromDhcp;
     this.current.host            = this.origin.host;
     this.current.ip              = this.origin.ip;
     this.current.subnet          = this.origin.subnet;
     this.current.dns             = this.origin.dns;
     this.current.gateway         = this.origin.gateway;
     this.current.dhcp            = this.origin.dhcp;
     this.current.ntpServers      = this.origin.ntpServers;
     this.current.useNtpFromDhcp  = this.origin.useNtpFromDhcp;
     this.current.dnsServer       = this.origin.dnsServer;
     this.current.useDnsFromDhcp  = this.origin.useDnsFromDhcp;
     this.current.zeroConfEnabled = this.origin.zeroConfEnabled;
     this.current.netProtocols    = this.origin.netProtocols;
     this.current.discoveryMode   = this.origin.discoveryMode;
 }
Exemplo n.º 14
0
        /// <inheritdoc/>
        public async Task SetDiscoveryModeAsync(string discovererId,
                                                DiscoveryMode mode, DiscoveryConfigApiModel config, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(discovererId))
            {
                throw new ArgumentNullException(nameof(discovererId));
            }
            var uri = new UriBuilder($"{_serviceUri}/v2/discovery/{discovererId}")
            {
                Query = $"mode={mode}"
            };
            var request = _httpClient.NewRequest(uri.Uri, _resourceId);

            request.SetContent(config);
            var response = await _httpClient.PostAsync(request, ct).ConfigureAwait(false);

            response.Validate();
        }
Exemplo n.º 15
0
        void DiscoveryTest()
        {
            try
            {
                BeginTest();

                System.Diagnostics.Debug.WriteLine(string.Format("{0}, Before GetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));
                DiscoveryMode backup = GetDiscoveryMode();
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, After GetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));

                // Set Discoverable

                System.Diagnostics.Debug.WriteLine(string.Format("{0}, Before SetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));
                SetDiscoveryMode(DiscoveryMode.Discoverable);
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, After SetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));

                System.Diagnostics.Debug.WriteLine(string.Format("{0}, Before GetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));
                DiscoveryMode afterSet = GetDiscoveryMode();
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, After GetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));

                Assert(afterSet == DiscoveryMode.Discoverable);

                System.Diagnostics.Debug.WriteLine(string.Format("{0}, Before SetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));
                SetDiscoveryMode(DiscoveryMode.NonDiscoverable);
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, After SetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));

                System.Diagnostics.Debug.WriteLine(string.Format("{0}, Before GetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));
                afterSet = GetDiscoveryMode();
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, After GetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));

                Assert(afterSet == DiscoveryMode.NonDiscoverable);

                System.Diagnostics.Debug.WriteLine(string.Format("{0}, Before SetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));
                SetDiscoveryMode(backup);
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, After SetDiscoveryMode", System.DateTime.Now.ToString("HH:mm:ss ffffff")));

                EndTest();
            }
            catch (Exception ex)
            {
                StepFailed(ex);
                TestFailed(ex);
            }
        }
            public static Model Create(
                bool useHostFromDhcp,
                string host,
                string ip,
                string subnet,
                string dns,
                string gateway,
                bool dhcp,
                string ntpServers,
                bool useNtpFromDhcp,
                string dnsServer,
                bool useDnsFromDhcp,
                bool zeroConfSupported,
                bool zeroConfEnabled,
                string zeroConfIp,
                NetworkProtocol[] netProtocols,
                bool discoveryModeSupported,
                DiscoveryMode discoveryMode
                )
            {
                var _this = new Model();

                _this.zeroConfSupported      = zeroConfSupported;
                _this.zeroConfIp             = zeroConfIp;
                _this.discoveryModeSupported = discoveryModeSupported;
                _this.origin.useHostFromDhcp = useHostFromDhcp;
                _this.origin.host            = host;
                _this.origin.ip              = ip;
                _this.origin.subnet          = subnet;
                _this.origin.dns             = dns;
                _this.origin.gateway         = gateway;
                _this.origin.dhcp            = dhcp;
                _this.origin.ntpServers      = ntpServers;
                _this.origin.useNtpFromDhcp  = useNtpFromDhcp;
                _this.origin.dnsServer       = dnsServer;
                _this.origin.useDnsFromDhcp  = useDnsFromDhcp;
                _this.origin.zeroConfEnabled = zeroConfEnabled;
                _this.origin.netProtocols    = netProtocols;
                _this.origin.discoveryMode   = discoveryMode;
                _this.RevertChanges();

                return(_this);
            }
Exemplo n.º 17
0
        //
        // Constructor
        //
        public DiscoveryServer(DiscoveryMode mode)
        {
            m_mode       = mode;
            m_dataSocket = new DatagramSocket();

            // Register for message callbacks. We do this both on the server and client
            // so the client can invoke the server when it comes online.
            m_dataSocket.MessageReceived += DataSocket_MessageRecieved;
            new Task(async() =>
            {
                try
                {
                    await m_dataSocket.BindServiceNameAsync(GLOW_SERVER_DISCOVER_PORT + "");
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("UDP unable to bind to port!. Message: " + e.Message);
                }
            }).Start();
        }
Exemplo n.º 18
0
        //
        // Constructor
        //
        public DiscoveryServer(DiscoveryMode mode)
        {
            m_mode = mode;
            m_dataSocket = new DatagramSocket();

            // Register for message callbacks. We do this both on the server and client
            // so the client can invoke the server when it comes online.
            m_dataSocket.MessageReceived += DataSocket_MessageRecieved;
            new Task(async () =>
            {
                try
                {
                    await m_dataSocket.BindServiceNameAsync(GLOW_SERVER_DISCOVER_PORT + "");
                }
                catch(Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("UDP unable to bind to port!. Message: " + e.Message);
                }                    
            }).Start();  
        }
Exemplo n.º 19
0
        internal static string ToSerializedValue(this DiscoveryMode value)
        {
            switch (value)
            {
            case DiscoveryMode.Off:
                return("Off");

            case DiscoveryMode.Local:
                return("Local");

            case DiscoveryMode.Network:
                return("Network");

            case DiscoveryMode.Fast:
                return("Fast");

            case DiscoveryMode.Scan:
                return("Scan");
            }
            return(null);
        }
Exemplo n.º 20
0
        private void btnGetDiscoveryMode_Click(object sender, EventArgs e)
        {
            try
            {
                DeviceClient service = GetService();

                DiscoveryMode discoveryMode = service.GetDiscoveryMode();
                ShowStatusMessage("Done");
                service.Close();

                if (cbShowResult.Checked)
                {
                    string         methodInfo = "Result from GetDiscoveryMode";
                    QuickWatchForm form       = new QuickWatchForm(methodInfo, discoveryMode);
                    form.Show();
                }
            }
            catch (Exception ex)
            {
                ShowStatusMessage("Operation failed");
                TraceException(ex);
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 21
0
        void Start()
        {
            // initialize discovery
            Initialize();
            //// set data
            broadcastData = gameName;

            DiscoveryMode mode = ServerManager.Instance.mode;

            // android devices allways start as clients
#if UNITY_ANDROID && !UNITY_EDITOR
            mode = DiscoveryMode.Client;
#endif

            if (mode == DiscoveryMode.Both || mode == DiscoveryMode.Client)
            {
                //// start listening
                StartCoroutine(StartAsClientDelayed());
            }

            if (mode == DiscoveryMode.Both || mode == DiscoveryMode.Server)
            {
                float delay = 0.2f;

                // set a delay if mode is set to both
                if (mode == DiscoveryMode.Both)
                {
                    delay = 5;
                }

                //// set broadcast coroutine
                initiateServerStartCoroutine = InitiateServerStart(delay);
                //// start broadcast coroutine
                StartCoroutine(initiateServerStartCoroutine);
            }
        }
 protected override void Cleanup()
 {
     ConsumedService.GetValueOrDefault()?.Dispose();
     ConsumedService = default;
     DiscoveryMode   = default;
 }
Exemplo n.º 23
0
 protected void SetDiscoveryMode(DiscoveryMode mode)
 {
     BeginStep(string.Format("SetDiscoveryMode({0})", mode));
     Client.SetDiscoveryMode(mode);
     StepPassed();
 }
Exemplo n.º 24
0
 protected IAsyncResult BeginSetDiscoveryMode(DiscoveryMode mode)
 {
     BeginStep("SetDiscoveryMode");
     return(Client.BeginSetDiscoveryMode(mode, null, null));
 }
Exemplo n.º 25
0
 void IOnVifDevice.SetDiscoveryMode(DiscoveryMode DiscoveryMode)
 {
     Console.WriteLine("SetDiscoveryMode operation requested!");
     this._discoveryMode = DiscoveryMode;
 }
Exemplo n.º 26
0
 void IOnVifDevice.SetRemoteDiscoveryMode(DiscoveryMode RemoteDiscoveryMode)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
 protected void SetDiscoveryMode(DiscoveryMode mode)
 {
     RunStep(() => { Client.SetDiscoveryMode(mode); }, "Set Discovery Mode");
     DoRequestDelay();
 }
Exemplo n.º 28
0
 public override void SetRemoteDiscoveryMode(DiscoveryMode RemoteDiscoveryMode)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 29
0
 public OnvifSetDiscoveryMode(string uri, string userName, string password, DiscoveryMode discoveryMode)
     : base(uri, userName, password)
 {
     DiscoveryMode = discoveryMode;
 }
Exemplo n.º 30
0
 /// <inheritdoc/>
 public Task ConfigureAsync(DiscoveryMode mode, DiscoveryConfigModel config)
 {
     _request = new DiscoveryRequest(mode, config);
     return(Task.CompletedTask);
 }