Click here to Skip to main content
6,630,289 members and growing! (22,079 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Game Development » General     Intermediate License: The Code Project Open License (CPOL)

Multi-Threaded Game Server Browser

By Greenhorn999

A project that allows users to query Source and Half-Life-based master servers and individual servers
VB, .NET (.NET 3.5), All Topics, Architect, Dev, QA, Design, SysAdmin
Version:4 (See All)
Posted:19 Jun 2009
Updated:19 Jun 2009
Views:4,794
Bookmarked:7 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
8 votes for this article.
Popularity: 4.19 Rating: 4.64 out of 5

1

2
1 vote, 12.5%
3

4
7 votes, 87.5%
5

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:  

' How to get all data about a game server
' The two main types of games supported with this implementation are:
' GameType.Source and GameType.HalfLife
' Use these objects in the QueryServer() method for testing.

Dim Server as GameServer(IP as String, Port as Integer, GameType as Object)
Server.QueryServer() 
' How to display current players and current stats in a listbox:

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 
' How to display game server CVAR results in a listbox:

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 
' How to display game server properties in a textbox:

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!!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Greenhorn999


Member
Adam Lawson is a Sr. Windows Engineer at Blue Shield of California (USA). He has collection of useless papers collecting dust include an MCSE 2k3, MCSD.Net, CCNA, A+, Network+ and a piece of lint he found while doing the laundry. He enjoys speaking proper English, prefers MSSQL over flat files and still plans to earn a million dollars by age 30. That's a tall order considering he is 38 now.

He is also a contributing author for TrainSignal and Windows IT Pro Magazine.
Occupation: Software Developer
Location: United States United States

Other popular Game Development articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
GeneralFYI - Project was converted from C# to VB.NET PinmemberGreenhorn9996:41 22 Jun '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 19 Jun 2009
Editor: Deeksha Shenoy
Copyright 2009 by Greenhorn999
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project