GameStat.NET Reference

ServerInfo.QueryMaster Method (MasterType)

[This is preliminary documentation and subject to change.]

Creates a new instance of the ServerCollection class and queries a master server.

public static ServerCollection QueryMaster(
   MasterType type
);

Parameters

type
One of the MasterType values.

Return Value

A new ServerCollection class initialized with server information, or null if the master server didn't return any.

Exceptions

Exception TypeCondition
SocketExceptionAn error occurred when attempting to access the master server.
ArgumentOutOfRangeExceptionThe given type is not recognized by GameStat.
ArgumentExceptionAn invalid argument was given.
NotImplementedExceptionSupport for the given type is not implemented yet.
CorruptPacketExceptionA currupt or unknown packet was recieved from the master server.

Example

This example queries the Counter-Strike master server and writes the resulting information to the console.

[C#]
try {
   ServerCollection servers=ServerInfo.QueryMaster(MasterType.Counter-Strike);
   
   if(servers!=null) {
      foreach(Server s in servers)
         Console.WriteLine(s.Host+":"+s.Port.ToString());
   }
   else Console.WriteLine("Master server didn't return any servers.");
}
catch(Exception ex) {
   Console.Error.WriteLine("An Exception Occured!");
   Console.Error.WriteLine(ex.ToString());
}

See Also

ServerInfo Class | GameStat Namespace | ServerInfo.QueryMaster Overload List