Valhalla Legends Forums Archive | Battle.net Bot Development | [C#] Getting complete server lists

AuthorMessageTime
-MichaeL-
[s]This is a bit off topic, but[/s] here is a great way to always have a complete up to date server list in C#.

[code]
   static class clsServers
   {
       public static List<clsServer> Servers = new List<clsServer>();
       /// <summary>
       /// Retrieve battle.net's server list.
       /// </summary>
       public static void Init()
       {

           //Populate server list
           GetServerList("USWest.battle.net", "@USWest", "@Lordaeron");
           GetServerList("USEast.battle.net", "@USEast", "@Azeroth");
           GetServerList("Europe.battle.net", "@Europe", "@Northrend");
           GetServerList("Asia.battle.net", "@Asia", "@Kalimdor");
       }

       private static void GetServerList(string server, string tag1, string tag2)
       {
           IPAddress[] result = Dns.GetHostEntry(server).AddressList;
           Servers.Add(new clsServer(server, tag1, tag2));
           foreach (IPAddress ip in result)
           {
               Servers.Add(new clsServer(ip.ToString(), tag1, tag2));
           }
       }
   }

   class clsServer
   {
       public string ServerIP;
       public string LegacyTag;
       public string WAR3Tag;

       public clsServer(string serverip, string legacytag, string war3tag)
       {
           ServerIP = serverip;
           LegacyTag = legacytag;
           WAR3Tag = war3tag;
       }
   }
[/code]

This allows for both domain names and IP's to be used as an address for the battle.net server.

[code]
           IPAddress[] result = Dns.GetHostEntry(server).AddressList;
[/code]
Gets all the IP's from the specified sub domain name that can be used to logon to battle.net

[MyndFyre edit: Split from the Regex for capturing topic /]
August 6, 2009, 9:29 PM
Sixen
Do you want it to be 100% complete?
[CODE]
GetServerList("Beta.battle.net", "@ClassicBeta", "@Westfall");
GetServerList("demo.war3.battle.net", "", "");
[/CODE]


The first is the PTR server on Battle.net, the second is the War3 Demo server, which has no namespace as far as i'm aware. Although, I haven't done much testing on it. It's basically a stripped down Battle.net server, but it is still a Battle.net server nonetheless.
August 7, 2009, 7:43 AM
-MichaeL-
Do you think it's wise to include beta servers to a bot the average user is going to be using?
August 12, 2009, 12:33 AM
MyStiCaL
the point is to handle all aspects, what's one line to make it less limited?
August 12, 2009, 12:47 AM
-MichaeL-
It may confuse the less educated.
August 12, 2009, 1:30 AM
Myndfyr
[quote author=-MichaeL- link=topic=18034.msg183193#msg183193 date=1250040628]
It may confuse the less educated.
[/quote]

Is that why you prefix a class name with "cls"?
August 12, 2009, 3:10 AM
-MichaeL-
Yes, it's a VB6 habit however it doesn't hurt.
August 12, 2009, 3:52 AM
Sixen
[quote author=-MichaeL- link=topic=18034.msg183190#msg183190 date=1250037225]
Do you think it's wise to include beta servers to a bot the average user is going to be using?
[/quote]

Yes, otherwise you shouldn't say "complete up to date server list".
August 12, 2009, 7:43 AM

Search