Creates a new instance of the ServerCollection class and queries a master server.
A new ServerCollection class initialized with server information, or null
if the master server didn't return any.
Exception Type | Condition |
---|---|
SocketException | An error occurred when attempting to access the master server. |
ArgumentOutOfRangeException | The given type is not recognized by GameStat. |
ArgumentException | An invalid argument was given. |
NotImplementedException | Support for the given type is not implemented yet. |
CorruptPacketException | A currupt or unknown packet was recieved from the master server. |
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());
}
ServerInfo Class | GameStat Namespace | ServerInfo.QueryMaster Overload List