Server search?

Posted By: khanoftruth

Server search? - 02/25/07 23:17

Has anyone successfully created a visual server finder (like those present in many FPS's). I want players to be able to join the server across internet. It would need to search for servers and display them so that users could click and join.

Examples include the Halo or Swat 4 or CS servers.

I don't want to hear about cost or size or server limitations. I just want to know if anyone created one.

If you did, could you explain how. Thanks.
Posted By: xXxGuitar511

Re: Server search? - 02/26/07 04:23

You don't actually "search" the internet for other players. When a user creates a session, you need to have that session store it's info in a database on YOUR own server. Then when a user searches for available sessions, they query the database for hosts (title of session + ping rate + etc). Then they select one, you get the info they need from it (IP address).
Posted By: khanoftruth

Re: Server search? - 02/26/07 05:44

I see. Did you create said visual database log? Or just theoretical (means I have to make it from scratch).
Posted By: xXxGuitar511

Re: Server search? - 02/26/07 14:28

You have to make it...

Check out the MySQL thread in the user contributions... This will allow you to read/write to your database.
Posted By: Excessus

Re: Server search? - 02/26/07 14:59

I've made such a system for a client once.

What I did was create a few php scripts that fetch the list of servers (with an optional selection, like only deathmatch games), add a server to the list, remove a server from the list (note that you will also have to put in a timeout for servers that 'forget' to remove themselves from the list.

Then just run those scripts on a webserver with a database and call those webpages from c-script with the GSHTTP plugin (search for it).

If you go with the MySQL plugin, make sure you give the database user only the privileges it needs, because the MySQL plugin sends entire queries to the server. A hacker might send a query that corrupts your database. If you use the php approach, you can disallow TCP traffic for your database, so that only the queries that are created by your php script can be executed (still have to be carefull with SQL injection then!).
Posted By: khanoftruth

Re: Server search? - 02/26/07 21:14

Thanks guys. Big help.
Posted By: broozar

Re: Server search? - 02/28/07 20:03

Quote:

What I did was create a few php scripts that fetch the list of servers (with an optional selection, like only deathmatch games), add a server to the list, remove a server from the list (note that you will also have to put in a timeout for servers that 'forget' to remove themselves from the list.




that's exactly what i am programming atm, same approach (php/GS_HTTP). are you using a flatfile base or MySQL?

i decided for the flatfile system. i hang on 2 points,
--->1) how do you create the timeout? i thought about
a)just displaying the files whose age is under 2 hours (bad, the server could be on for less time)
b)before exiting, sending a "delete entry"-command (bad, what if the game crashes?)
--->2)making a file on the server is no problem. retrieving data from a whole buch of files is (disadvantage of flatfile system i guess). sometimes i do not get a response quick enough, and GS_HTTP is showing "".
Posted By: Excessus

Re: Server search? - 03/04/07 12:27

I used MySQL. A flatfile system should work fine aswell (don't see any disadvantage unless the load becomes very high). I chose to go with MySQL because I knew SQL but not php at that time, so this seemed the easyest. I still think building SQL queries is easyer than "file fidling".

You should store the datetime in a column and remove those rows who where created more than x seconds/minutes ago, where x is either a static number or a setting that the client can be set within some range by the client. There are datetime compare functions in SQL databases, but for your flatfile system I would just use the system time and count seconds/minutes.

The problem is probably WHEN to do this removal. To always get an up to date list, you must remove all outdated rows before retrieval. In your case, you'll have to check all the rows and remove all outdated ones and then return the rest.

If you expect a very high load on this server, a more efficient but less accurate solution is to only remove rows once every x retrievals (use a counter). You can probably also remove outdated rows periodically, without client interaction but I don't know how.

To improve on this system, you could add a php file that removes a certain client at any given time and let the game server (not the central server) call this when it cancels the game. This does raise security concerns (anyone can use this php file, even from a browser, with any parameters) so you might want to add a random password that is decided by the game server when it joins.

You could also add a way to 'report' crashed/disconnected game servers. If you try to connect to a server from the list and it doesn't work, report that to the central server. The central server checks if it indeed can't connected and removes it if it really crashed/disconnected.

Good luck
Posted By: fastlane69

Re: Server search? - 03/04/07 16:34

I don't know php but we've been using MySql for close to a year and I have to say it is the way to go. The MySql plugin is great (has a small memory leak but nothing major), MySql is free, and it's actually easy to setup and use!

Not adding much to the discussion here except to say that if you can, take the time to play with MySql and use it instead of a flatfile system whenever you can... whatever time you spend learning it will pay off in droves in the future in terms of lowered development times and increased performance.
Posted By: Excessus

Re: Server search? - 03/04/07 18:53

Quote:

Not adding much to the discussion here except to say that if you can, take the time to play with MySql and use it instead of a flatfile system whenever you can... whatever time you spend learning it will pay off in droves in the future in terms of lowered development times and increased performance.




Yes I agree. Learning SQL will be beneficial, especialy if you expect your system to become more complex, or if it must be very fast under heavy load. Also, since MySQL (and I believe some other RDBMSs aswell) are seamlessly integrated with php, it will be a breeze if you know SQL. However, if you don't know SQL yet, you might want to go with flatfiles if you know it will not be under heavy load and you have to get it done quickly.

Quote:

MySql is free, and it's actually easy to setup and use!



While setting up MySQL is indeed extremely easy, optimizing the settings and your queries is quite challenging. If you don't do it right, flatfiles might give better performance (especially when the load isn't very high).

Quote:

The MySql plugin is great (has a small memory leak but nothing major)



Just FYI:
The way the system I proposed works is that you retrieve a webpage from within 3DGS. This webpage is dynamically created by a php script that runs on the central server. The page is basically a reflection of the database contents. As you can see, you don't need the MySQL plugin here and using it for this purpose (bypassing the HTTP request and the php script; talking directly to the database) will bring you alot of security issues (this is very different from your project where only the server -hosted by you only- directly talks to the database (or atleast I hope so for you )).
© 2024 lite-C Forums