Пример #1
0
        private async Task RespondToV2Message(string messageText, string endpoint, Encoding encoding)
        {
            var parts = messageText.Split('|');

            var localUrl = await _appHost.GetLocalApiUrl().ConfigureAwait(false);

            if (!string.IsNullOrEmpty(localUrl))
            {
                var response = new ServerDiscoveryInfo
                {
                    Address = localUrl,
                    Id = _appHost.SystemId,
                    Name = _appHost.FriendlyName
                };

                await SendAsync(encoding.GetBytes(_json.SerializeToString(response)), endpoint).ConfigureAwait(false);
                
                if (parts.Length > 1)
                {
                    _appHost.EnableLoopback(parts[1]);
                }
            }
            else
            {
                _logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
            }
        }
Пример #2
0
        private async void RespondToV2Message(string endpoint)
        {
            var localAddress = GetLocalIpAddress();

            if (!string.IsNullOrEmpty(localAddress))
            {
                var serverAddress = string.Format("http://{0}:{1}", localAddress, _serverConfigurationManager.Configuration.HttpServerPortNumber);

                var response = new ServerDiscoveryInfo
                {
                    Address = serverAddress,
                    Id = _appHost.ServerId,
                    Name = _appHost.FriendlyName
                };

                await SendAsync(Encoding.UTF8.GetBytes(_json.SerializeToString(response)), endpoint);
            }
            else
            {
                _logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
            }
        }
Пример #3
0
        private async void RespondToV2Message(string endpoint, Encoding encoding)
        {
            var localUrl = _appHost.LocalApiUrl;

            if (!string.IsNullOrEmpty(localUrl))
            {
                var response = new ServerDiscoveryInfo
                {
                    Address = localUrl,
                    Id = _appHost.SystemId,
                    Name = _appHost.FriendlyName
                };

                await SendAsync(encoding.GetBytes(_json.SerializeToString(response)), endpoint);
            }
            else
            {
                _logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
            }
        }
Пример #4
0
        private async void RespondToV2Message(string endpoint)
        {
            var info = _appHost.GetSystemInfo();

            if (!string.IsNullOrEmpty(info.LocalAddress))
            {
                var response = new ServerDiscoveryInfo
                {
                    Address = info.LocalAddress,
                    Id = info.Id,
                    Name = info.ServerName
                };

                await SendAsync(Encoding.UTF8.GetBytes(_json.SerializeToString(response)), endpoint);
            }
            else
            {
                _logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
            }
        }
Пример #5
0
        private string ConvertEndpointAddressToManualAddress(ServerDiscoveryInfo info)
        {
            if (!string.IsNullOrWhiteSpace(info.Address) && !string.IsNullOrWhiteSpace(info.EndpointAddress))
            {
                var address = info.EndpointAddress.Split(':').First();

                // Determine the port, if any
                var parts = info.Address.Split(':');
                if (parts.Length > 1)
                {
                    var portString = parts.Last();
                    int port;
                    if (int.TryParse(portString, NumberStyles.Any, CultureInfo.InvariantCulture, out port))
                    {
                        address += ":" + portString;
                    }
                }

                return NormalizeAddress(address);
            }

            return null;
        }