Beispiel #1
0
        async Task AddServerOK()
        {
            var str = AddServerInput;

            if (String.IsNullOrWhiteSpace(str))
            {
                await _dialogManager.MessageBox(
                    new MessageBoxDialogParams(
                        "Please specify a valid ip address or hostname, specify the port separately down below"));

                return;
            }

            IPAddress ip;

            try {
                ip = SAStuff.GetValidIp(str);
            } catch (SocketException e) {
                await
                _dialogManager.MessageBox(
                    new MessageBoxDialogParams(
                        "Please specify a valid ip address or hostname, specify the port separately down below\nError: " +
                        e.Message)).ConfigureAwait(false);

                return;
            }

            var port = AddServerPort;

            if (port < 1 || port > IPEndPoint.MaxPort)
            {
                await _dialogManager.MessageBox(new MessageBoxDialogParams("Please specify a valid port"));

                return;
            }

            await Task.Run(async() => {
                var server = await TryFindOrCreateServer(new ServerAddress(ip, port));
                if (server == null)
                {
                    return;
                }

                server.IsFavorite    = true;
                var t                = server.TryUpdateAsync();
                LibraryVM.ActiveItem = server;
                AddServerInput       = null;
                IsAddServerVisible   = false;
            });
        }
Beispiel #2
0
 ServerAddress GetAddy() => SAStuff.GetAddy($"{_ip}:{(_port == 0 ? 2302 : _port)}");