Search Unity

Master server alternative

Discussion in 'Multiplayer' started by dreammakersgroupAdmin, May 19, 2012.

  1. dreammakersgroupAdmin

    dreammakersgroupAdmin

    Joined:
    Feb 13, 2012
    Posts:
    40
    I am making multiplayer networking game, I am using unity master server.
    but it looks like it is for testing purpose and i don't need to go with busy server.

    is there any 3d party company can support my master server?
    any idea?
    what is best solution?
     
  2. atrakeur

    atrakeur

    Joined:
    Jun 14, 2011
    Posts:
    134
    Hi!

    Actually I've got a master server writen in php up and running on a standard web environnement.
    It's still in beta, I've started it last week.
    From what I can see in the logs, it seems to work pretty well, and no one has complained about it.
    It's writed in OO php for the framework CodeIgniter, works with only one table in a database so that it can run on any webserver.

    I've done a NetMaster class that mimics the Master class from built in networking code (same functions, same parameters, start to work with a simple search replace)

    That's to say that you can do easily your own master server in any langage...

    If you want to, you can use my master server for free (using my NetMaster class). The only thing I want is that you send back to me any issues you and your customers will run into with it...
    As long as you don't use too much traffic (for example 10 000 copies of the game, running servers and requesting list at the same time), I can help you with the hosting.

    Or you can juste search the forum, I think there is some similar free code to do that...
     
  3. Mohican

    Mohican

    Joined:
    May 17, 2012
    Posts:
    49
    I recently wrote an XML-RPC Master Server in Python.
    It took me only a day to program a server supporting: Login, Stats, Clans, Messaging...

    After setting up a home server running MySQL+Python, I just ran the script and was all set!
    I then implemented the Client-side in Unity using this information: http://stackoverflow.com/questions/7158530/unity3d-xml-rpc-and-c-sharp

    I would strongly recommend using Python XML-RPC, rather than PHP (I tried both!).
    The python code is way faster to implement and maintain. Here's a quick (working!) example to wet your appetite (P.S: This stupid forum doesn't show indentation properly...):

    Code (csharp):
    1.  
    2. import _mysql
    3. from SimpleXMLRPCServer import SimpleXMLRPCServer
    4.  
    5. # MySQL parameters
    6. global auth_host, auth_user, auth_pwd, auth_db
    7. auth_host = 'localhost'
    8. auth_user = 'root'
    9. auth_pwd = 'password'
    10. auth_db = 'mydb'
    11.  
    12. # XMLRPC parameters
    13. global xhost, xport
    14. xhost = 'localhost'
    15. xport = 1025
    16.  
    17. ###################
    18. # Useful functions
    19. def Process_Query(query):
    20.     # Fail safe MySQL query, with auto-reconnection
    21.     global auth_conn
    22.     try:
    23.         auth_conn.query(query)
    24.     except:
    25.         # Reconnect to MySQL, and try again
    26.         auth_conn = _mysql.connect(auth_host, auth_user, auth_pwd, auth_db)
    27.         auth_conn.query(query)
    28.  
    29.     # Fetch result
    30.     result = auth_conn.use_result()
    31.  
    32.     # Return result rows
    33.     if result is not None:
    34.         rows = result.fetch_row(0)
    35.         if len(rows) == 0:
    36.             return None
    37.         else:
    38.             return rows
    39.     else:
    40.         return None
    41.  
    42.  
    43. ##################
    44. # Client Commands
    45. def Client_Login(Username, Password):
    46. #
    47. # Username: string
    48. # Password: string
    49. #
    50. # Output Dictionary: {
    51. #                     'UID' : integer,
    52. #                     'ClanID' : integer,
    53. #
    54.     data = {}
    55.  
    56.     # Find Client
    57.     result = Process_Query('SELECT UID, clan_id FROM auth WHERE username="%s" AND password=MD5("%s")' % (Username, Password))
    58.     if result is None:
    59.         data['Error'] = 'Incorrect Username or Password! (%s:%s)\n' % (Username, Password)
    60.         return data
    61.  
    62.     # Put info in dictionary
    63.     data['UID'] = int(result[0][0])
    64.     data['ClanID'] = int(result[0][1])    
    65.     return data
    66.  
    67.  
    68. ##################
    69. # Initialize XML-RPC server            
    70. xmlprc = XMLRPCServer((xhost, xport), requestHandler=RequestHandler)
    71. xmlprc.register_function(Client_Login, "Client_Login")
    72.  
    73. # Start listening
    74. print "Listening on port %i..." % (xport)
    75. xmlprc.serve_forever()
    76.  
     
    Last edited: May 21, 2012
  4. dreammakersgroupAdmin

    dreammakersgroupAdmin

    Joined:
    Feb 13, 2012
    Posts:
    40
    i like the idea, especially i can run it in any web hosting, i will do some search
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Use code tags for indentation. See advanced, when posting.
     
  6. Mohican

    Mohican

    Joined:
    May 17, 2012
    Posts:
    49
    Ok, fixed it!