Ejemplo n.º 1
0
        private void addToList(TVServer server, String ping)
        {
            ListViewItem newItem = new ListViewItem(new String[] { server.serverName, ping, server.mapName, server.gameType, server.numPlayers + "/" + server.maxPlayers, server.ipAddress + ":" + server.port, server.password, server.adminEmail });

            newItem.Tag = server;
            lstServers.Invoke((MethodInvoker) delegate { lstServers.Items.Add(newItem); });
        }
Ejemplo n.º 2
0
        private void getServerInfo(UdpClient socket, IPAddress address, int port)
        {
            String strAddress = String.Copy(address.ToString());

            IPEndPoint endPoint = new IPEndPoint(address, port);

            byte[] send_buffer = new byte[] { 0x5c, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5c, 0x00 }; // "\status\."

            try
            {
                socket.Send(send_buffer, 9, endPoint);

                byte[] info = socket.Receive(ref endPoint);


                String longServerInfo = System.Text.Encoding.Default.GetString(info);

                TVServer server = new TVServer(longServerInfo, strAddress);

                if (server.isValid())
                {
                    tvServers.Add(server);

                    Ping pingSender = new Ping();

                    string      data    = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
                    byte[]      buffer  = Encoding.ASCII.GetBytes(data);
                    int         timeout = 2000;
                    PingOptions options = new PingOptions(64, false);

                    PingReply reply = pingSender.Send(server.ipAddress, timeout, buffer, options);

                    if (reply.Status == IPStatus.Success)
                    {
                        addToList(server, reply.RoundtripTime.ToString());
                    }
                    else
                    {
                        addToList(server, "N/A");
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 3
0
        private void selectItem(ListViewItem item)
        {
            try
            {
                String gamePath = getGameLocation();

                if (gamePath.Trim().Length <= 0)
                {
                    gamePath = getGameLocation();
                }

                if (gamePath.Trim().Length > 0)
                {
                    TVServer server = (TVServer)item.Tag;
                    openTribes(gamePath, server.ipAddress, server.port);
                }
            }
            catch (Exception e)
            {
                MessageBoxEx.Show(this, "Error while opening game:\r\n" + e.ToString() + "\r\n\r\nYou might have the wrong game path set.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }