Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 38

Thread: Source Code for Current C# Implementation

  1. #11

    Default

    I copied the solution over again, and this time I can open it just fine. This is the source for only the service, correct? Where did MoHMasterserver Manager come from and do you have the source to that? It looks like you're already threading the start method, so what's the issue? Can you describe to me how to recreate the problems you're experiencing? I can start the service, but it doesn't do anything. I think that's because reborn servers have been told to send the packets to a particular IP / server?

    Wouldn't it be better and faster to check and see if the server information exists before attempting to insert the IP? Right now, if the insert fails because it already exists, it then calls the update method. It should run a query to see if it already exists first and then decide what to do.

    Other than that... the application looks simple, though I have no idea how the sending of packets, receiving of packets, or what format the packets are in work. Maybe you can explain that too me? This is a good program to study. I've never done anything like this yet. Good stuff RR
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  2. #12
    Administrator JoTo's Avatar
    Join Date
    May 2010
    Location
    www.scapp.net
    Posts
    1,953

    Default

    Quote Originally Posted by own3mall View Post
    Wouldn't it be better and faster to check and see if the server information exists before attempting to insert the IP? Right now, if the insert fails because it already exists, it then calls the update method. It should run a query to see if it already exists first and then decide what to do.
    There is allready a combined sql command for that: Replace

    The running thread should set property to isbackground=true. Other than that if it works it works. Don't see why you have issues with it, might be a windows problem itself.
    I personally would code the udp server itself with asynchronous socket and pooled buffers, and processing without Linq (never used it, and won't as I believe it only adds avoidable complexity - beside that I believe its not fast)

    I think it could be easy enhanced to act as a master server in general. I dont have the proto specification at hand now, but run a home server with wincap/wireshark and you can quickly discover.

  3. #13
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    The issue is as follows:

    Service once installed, runs automatically at startup of the machine (OS).
    When Heatsinkbod restarts the box, service sometimes fails to start, and is off. This can't be happening.

    What I suspect is that service initialization takes too long at startup and that is why it fails. There is a certain time window you have to fit in, otherwise OS will shut down the service and won't wait for it to start.

    I'm not sure if thats the case but I suspect this. Another possibility is that C# waits to initialize MySQL library, and to do so, it needs to load it's VM/CLR and init whole .NET which lasts too long.

    Now it checks Registry, and starts the server socket before running the thread. I'd move the socket part, and registry part to the thread, remove the request for additional time (it was used to tackle the problem).

    I'd change the SQL checks for this:
    http://dev.mysql.com/doc/refman/5.0/...duplicate.html

    Manager is just a simple C# app to register the service, and manage it (start, stop, restart etc.) and it works properly.

    And as JoTo mentioned, it should be rewritten so it uses async connection and events/callbacks, or actually.. have one master socket and spawn threads for new incoming "connections" (UDP is connectionless ;p). So it doesn't block other requests from other reborn servers. This is quite important because with UDP, awaiting packet might get lost if it waits too long to be received.

    The packet scheme is as follows:

    0xFF 0xFF 0xFF 0xFF 0x01 - server UDP packet header
    text command (heartbeat)
    game id (mohrb)

    So it's: 0xFF 0xFF 0xFF 0xFF 0x01 heartbeat mohrb

    just that simple. MoHAA (non Reborn) packets look different because they use GSA protocol and not standard Quake3 one.

    The server doesn't support any other commands but can be extended to do so, as you can see from the code.

  4. #14
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    interesting,

    Why is the service starting mysql? Why isnt mysql starting anyway...and if its an MS system..why not just use MSSQL...which works just as good and should probably init a bit better

    linq is awesome but not needed here.

    ive not played with c# really or services so if you get bored, i would quite enjoy doing this myself. in a week or so...i cant iamgine its much work

    if its not running async,it should be

    but i cant actually imagine its getting so much traffic that even mysql or threads are bulding up...mysql has to wait, but itts simple queries.

    maybe a nosql would be better? Which would be quite interesting to me to use..as im thinking about it for a future server system for myself..which is why this whole thing is interesting.

  5. #15

    Default

    I find this extremely interesting myself. I plan to tweak the C# version if no one else gets to it first.

    But right now, my interest has been stimulated. I'm writing a PHP script equivalent that uses mysql and sockets (Already got most of the code done... just needs to be tested --- I think it can work!). The script is run through an init bash script and runs locally over the server... not accessible through the web. I think this has the potential to work as well and will allow us to use Linux or Windows servers as the master server.

    Would it be possible for individual servers to send the server information to multiple master servers? And what's the format that needs to be sent back to clients when they query servers from the master server? Should that be sent as a socket_send message per server? This part doesn't seem to be implemented yet in the C# version because we're not officially using the reborn master server yet.

    Can you give us the database schema so I can create a test one... I know it's simple, but I'm lazy...

    Or dump the SQL...
    Last edited by own3mall; March 4th, 2013 at 09:44 PM.
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  6. #16

    Default

    Alright, I made quite a few changes. I have no idea if this is going to work, but it compiled. It should be using Asynchronous UDP Sockets (an OK guide here: http://msdn.microsoft.com/en-us/libr...inreceive.aspx). I also added the Insert but Update on Duplicate key assuming the key is composite (IP and Port Combo)... else it won't work. If it's not a composite key, use the old method... it's still in the code but commented. Hopefully I called ReceiveMessages() method appropriately. I'm not exactly sure here.

    I put my source in the OwN-3m-All folder in MoHAABox. Please check it out Razo... See what you think... it needs to be tested... make backups before running lol! Again, not sure if the call to run ReceiveMessages() method is in the correct place or should be called infinitely using the while(true).

    Assuming the primary key is a composite key consisting of IP and port, this method should work:

    Code:
    // Try to insert a new server ip and port --- If the IP and port already exist, update online and lastcheck
            public bool InsertUpdate(string ip, int port)
            {
                // Documented example:
                /* INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; */
    
                string query = "INSERT INTO server (IP, Port, LastCheck) VALUES('" + ip + "', '" + port.ToString() + "', NOW()) ON DUPLICATE KEY UPDATE LastCheck=NOW(), Online='1'";
                bool res = true;
    
                //open connection
                if (this.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, connection);
                    try
                    {
                        //Execute command
                        cmd.ExecuteNonQuery();
                    }
                    catch (MySqlException ex)
                    {
                        log.writeLine(ex.Message);
                        res = false;
                    } 
    
                    //close connection
                    this.CloseConnection();
                }
    
                return res;
            }
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  7. #17
    Administrator JoTo's Avatar
    Join Date
    May 2010
    Location
    www.scapp.net
    Posts
    1,953

    Default

    Quote Originally Posted by Razo[R]apiD View Post
    The issue is as follows:


    What I suspect is that service initialization takes too long at startup and that is why it fails. There is a certain time window you have to fit in, otherwise OS will shut down the service and won't wait for it to start.
    yes can be, the default waiting time is 30 or 60 seconds, but there is a command to tell the servicemanager that the service may take longer.

    this is the replace command: http://docs.oracle.com/cd/E17952_01/...n/replace.html

  8. #18
    Administrator JoTo's Avatar
    Join Date
    May 2010
    Location
    www.scapp.net
    Posts
    1,953

    Default

    Quote Originally Posted by Elgan View Post

    Why is the service starting mysql? Why isnt mysql starting anyway...and if its an MS system..why not just use MSSQL...which works just as good and should probably init a bit better
    mysql is probably starting separatly with the apache server


    Quote Originally Posted by Elgan View Post

    maybe a nosql would be better? Which would be quite interesting to me to use..as im thinking about it for a future server system for myself..which is why this whole thing is interesting.
    If its required one can code his own database system based on file(s), If you exactly know what data to store and you are not in need of a general concept like sql then its for sure an option as its up to 100 times faster than sql

  9. #19
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    OK. Service is not starting MySQL server. We use xNULL's MySQL database . Masterserver uses MySQL client library to connect to it and store data. You can find needed credentials in the source code.

    We use MySQL because this is what our hosting supports. This way we can run PHP Ajax-based queries to create a responsive online server browser. I didn't notice any stacking or blocking so even single thread worked fine. All the logic worked fine and was used to store server data in the DB.

    The problem was that service wouldn't always start together with dedi box restart. I don't remember the exact System Event exception but it had something to do with way too long initialization process, and this is why I suspected MySQL library or any code that is executed before main thread starts.

    own3mall -> php server script was also my initial thought and I considered it, but I don't remeber why I didn't do it that way. I also considered a Python implementation.

    It would be possible for Reborn servers to send information to more than one Masterserver but it's not implemented, however it's not hard to implement.

    Reborn clients don't use the Reborn masterserver yet and both masterserver's and reborn client's code is not done yet. We can try to implement it from scratch or we need to fit in GameSpy Arcade protocol (on masterserver's end), which will limit the amount of work needed to be done on client's end.

    There is a unique key made of IP and Port.


    Currently, Reborn Masterserver does nothing more than storing IP's and Port's of servers which ping it with UDP heartbeat packet.

    Online ServerBrowser uses this database to get IP's and Port's (AJAX) and uses PHP backend script (throught AJAX) to query reborn servers (getstatus, getinfo commands) so it can fill in table grid of available servers.

  10. #20
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    The scheme of a true ioquake3 masterserver <-> server communication looks like this:

    1. When server starts the game, it sends a heartbeat to masterserver.
    2. Masterserver queries the server for basic information and stores them in the DB.
    3. Server sends heartbeat each 5minutes to let masterserver know it's alive and so masterserver can have it's data updated
    4. When server goes down, it sends a heartbeat, so masterserver can query the server back and see it's down (it won't receive a response) and marks the server down or deletes it from the storage.

    Clients can query masterserver for stored servers and their basic data. When they hit a Refresh button, they query masterserver again for data from it's storage. Masterserver doesn't update it's storage on client's Refresh.

    This is why you have to hit refresh few times before you get an updated data sometimes (game server will have time to send the heartbeat packet and get queried again for new data).

    -----------------------------------------------------------

    Our masterserver doesn't query the server after receiving a heartbeat packet, so it doesn't create a local cached server data.
    Reborn servers doesn't send heartbeat when they go down.
    Our masterserver doesn't delete servers from the database, because we also want to keep all data for statistics (how many servers are running patch, or ran reborn at least once).

    These are the main differencies.

    You can test the masterserver by setting the CVar sv_rebornmaster (http://www.x-null.net/wiki/index.php...v_rebornmaster) to 127.0.0.1 localhost or any other IP where server resides. It's cheat protected so you have to run it with cheats to change it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •