Exemple #1
0
        protected override async Task SearchAsync(IPAddress gatewayAddress, TimeSpan?repeatInterval, CancellationToken token)
        {
            var buffer = gatewayAddress == null?DiscoverDeviceMessage.EncodeSSDP() : DiscoverDeviceMessage.EncodeUnicast(gatewayAddress);

            do
            {
                await Clients.SendAsync(buffer, gatewayAddress, token);

                if (!repeatInterval.HasValue)
                {
                    break;
                }
                await Task.Delay(repeatInterval.Value, token);
            } while (true);
        }
Exemple #2
0
        protected override async Task SearchAsync(IPAddress gatewayAddress, TimeSpan?repeatInterval, CancellationToken token)
        {
            var messages = gatewayAddress == null?DiscoverDeviceMessage.EncodeSSDP() : DiscoverDeviceMessage.EncodeUnicast(gatewayAddress);

            do
            {
                foreach (var message in messages)
                {
                    await Clients.SendAsync(message, gatewayAddress, token).ConfigureAwait(false);
                }
                if (!repeatInterval.HasValue)
                {
                    break;
                }
                await Task.Delay(repeatInterval.Value, token).ConfigureAwait(false);
            } while (true);
        }
Exemple #3
0
        protected override async void SearchAsync(IPAddress gatewayAddress, TimeSpan?repeatInterval, CancellationToken token)
        {
            var messages = gatewayAddress == null?DiscoverDeviceMessage.EncodeSSDP() : DiscoverDeviceMessage.EncodeUnicast(gatewayAddress);

            while (!token.IsCancellationRequested)
            {
                try {
                    foreach (var message in messages)
                    {
                        await Clients.SendAsync(message, gatewayAddress, token).ConfigureAwait(false);
                    }
                    if (!repeatInterval.HasValue)
                    {
                        break;
                    }
                    await Task.Delay(repeatInterval.Value, token).ConfigureAwait(false);
                } catch (OperationCanceledException) {
                    break;
                } catch (Exception ex) {
                    Log.Exception(ex, "Unhandled exception searching for a upnp device");
                }
            }
        }