private void Btn_connect_Click(object sender, EventArgs e) { if (lbx_connectList.SelectedIndex != -1) { connected(); GameNetworkUtilities.ServerStats serverStats = ips[lbx_connectList.SelectedIndex]; connectedIP = serverStats.Ip; connectedPort = lastPortScanned; playerName = txt_connectPlayerName.Text; lbx_lobbyPlayerList.Items.Add($"{playerName}\t\t(Local)"); setLobbyGameName(serverStats.GameName); lobbyClient = new LobbyClient(connectedIP, connectedPort, this, playerName); lobbyClient.connectToServer(); } }
private void Btn_manualConnect_Click(object sender, EventArgs e) { connectedIP = txt_connectIP.Text; connectedPort = int.Parse(txt_connectPort.Text); GameNetworkUtilities.ServerStats serverStats = GameNetworkUtilities.pingIP(connectedIP, connectedPort); if (serverStats.Equals(GameNetworkUtilities.INVALID_SERVER)) { MessageBox.Show($"Could NOT Ping {connectedIP}:{connectedPort}", "Could NOT Ping", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { connected(); playerName = txt_connectPlayerName.Text; lbx_lobbyPlayerList.Items.Add($"{playerName}\t\t(Local)"); setLobbyGameName(serverStats.GameName); lobbyClient = new LobbyClient(connectedIP, connectedPort, this, playerName); lobbyClient.connectToServer(); } }