Esempio n. 1
0
        private int GetID()
        {
            var id = txtClient.Text;

            if (string.IsNullOrEmpty(id))
            {
                throw new Exception("Please enter the id of a client.");
            }

            var isInt = int.TryParse(id, out var result);

            if (!isInt)
            {
                throw new Exception("Please enter a valid value.");
            }

            var clients = _listener.GetConnectedClients();

            if (!clients.Keys.Contains(result))
            {
                throw new Exception("The client with the ID " + result + " is not connected.");
            }

            return(result);
        }