Readme for Tlr.Freelancer.Network Library
bug reports to alexangelopoulos@hotmail.com

Who May Want This
People working with Freelancer multiplayer gaming who have some development knowledge and access to development tools that can access COM or .NET classes.

What the Library Is
Tlr.Freelancer.Network.dll is a .NET library that can be used to "ping" Freelancer servers and return some basic information.
It was built using Visual Studio 2003, but the source could be recompiled with the original .NET runtime version if you are using the first release of Visual Studio.NET. It can be referenced from any .NET project, and it is exposed via an exported TLB to COM automation, so you can also use it with Windows scripting projects or Visual Basic 5/6 by referencing the associated TLB file.
I provide the complete source code for the file, and as usual release it into the public domain so Freelancer players can easily reuse or modify it without worry about licensing and attribution.

How to Use It
Assuming you have referenced the project appropriately, you can then use the library to connect to a remote FL server and return stats.

How To Register For COM Use
If you are going to use VB or VBScript "late binding" (referencing the library with CreateObject), you must register it. Assuming you have the .NET runtime installed on your system, you just need to open a command prompt in the folder for the file and run the following command:
	regasm Tlr.Freelancer.Network.dll
You should see regasm's "banner" display, followed by the line
	Types registered successfully

An Example Using VBScript/WSH
The following demonstrates how you would use the library from Windows Script Host in a VBS file. VB5/6 usage will be similar (although WScript.Echo does NOT work in VB - you need to use MsgBox or a form to display text).

Your first step is to instantiate the library in your code: for example:
	Dim Net
	Set Net = CreateObject("Tlr.Freelancer.Network")
If this fails, you have not registered the library successfully (see the "How To Register for COM Use" section above).
You are now ready to check a Freelancer server. You MAY need to change the default port used for connections. The library uses 2302 by default, but you CAN change it by accessing the Port property. You would change the port to 2303 like this:
	Net.Port = 2303
Now you can query a specific server. If you're running FLServer locally (on port 2303) you can test the loopback IP address 127.0.0.1, like this:
	Dim result
	result = Net.QueryServer("127.0.0.1")
If the query succeeded - a server was indeed listening at that address on that port - result will be True(-1); if not, then the result is False(0). The following will echo back the result in script:
	WScript.Echo result
The rest of this is only useful for successful connections. To display the time in milliseconds it took for the response, do this:
	WScript.Echo Net.ResponseTime
You can see how many players are logged on using the PlayerCount property:
	WScript.Echo Net.PlayerCount
And you can view the maximum allowed number of players with PlayerMaximum:
	WScript.Echo Net.PlayerMaximum
