Introduction
This is a multi-threaded game server browser that supports Source and Half-Life-based games and mods. The main form provides an example of what the engine is currently capable of producing and is a simple stand-alone form. The game server query engine is encapsulated in a .DLL so it can be accessed and used by other projects or on a Windows webserver.
Background
Full disclosure; the code started with Franz Pentenrieder’s original project (gameserverinfo.aspx) which is now utterly deprecated because none of the protocols work anymore. I used his implementation as a starting point, corrected the Source and Half-Life protocols (after packet compression was introduced) then added master server queries with several different types of filtering to choose from.
Using the Code
Please reference the original project to understand how I got to this point. But here's some methods to get you started.
A basic game server has been made incredibly simple with the QueryServer()
method as shown below:
Dim Server as GameServer(IP as String, Port as Integer, GameType as Object)
Server.QueryServer()
For Each player As aQueryLib.aQueryLib.Player In Server.Players
Dim lvItem As New ListViewItem(New String() _
{GameServer.CleanName(player.Name), player.Score.ToString(), _
player.Ping.ToString(), player.Time.ToString()})
Me.lvPlayers.Items.Add(lvItem)
Next
For Each de As DictionaryEntry In Server.Parameters
Dim lvItem As New ListViewItem(New String() _
{de.Key.ToString(), de.Value.ToString()})
lvParams.Items.Add(lvItem)
Next
Dim props As PropertyInfo() = server.[GetType]().GetProperties_
(BindingFlags.[Public] Or BindingFlags.GetField Or BindingFlags.Instance)
For Each prop As PropertyInfo In props
Try
Dim obj As Object = prop.GetValue(server, Nothing)
If obj.ToString().IndexOf("Collection") <> -1 Then
Continue For
End If
tbInfos.Text += (prop.Name & " - ") + obj.ToString() _
& vbCr & vbLf
Catch generatedExceptionName As TargetInvocationException
Catch generatedExceptionName As NullReferenceException
End Try
Next
History
I would call Franz Pentenrieder’s original project Version 1 and mine would be Version 2 with a primary focus on Counter-Strike. Code written, optimized and improved by Adam Lawson. 6/17/2009
Enjoy!!!