Creating a new Realm at the Login Server - Kyoril/mmo GitHub Wiki

A login server will allow realm servers to connect to it. This is necessary so that the login server will allow players to redirect them to a realm once they have been authenticated, and the realm server needs a connection to a login server in order to check if connected players are allowed to log in as the account.

The Login Server REST API

For the rest of this page, I assume your login server has the ip address 12.34.56.78 which you can reach (this not a real ip, obviously!). I also assume that you already configured your login server properly and that you were able to launch it.

The login server should then host an HTTP server listening on Port 8090 which accepts HTTP POST requests. I usually recommend a tool like Postman to do the next step if you need to do it manually.

Authentication

The HTTP API is protected by basic authentication. That is, in Postman you need to go to the authorization tab, set the Auth Type to Basic Auth and enter a username and a password:

image

NOTE: The username and the password you need to enter are set in the login server config file config/login_server.cfg of your login server. There should be a section like this:

webServer = 
(
	port = 8090
	ssl_port = 8091
	user = "USERNAME"
	password = "PASSWORD"
)

These are the username and the password you need to enter when sending an HTTP request. You can change them in the config file to whatever you want. Just be sure to restart the login server after changing the config values.

Creating the actual realm server entry

Now it's time to send an actual request to create a new realm.

  1. Set the request method to "POST"
  2. Enter the correct full address (for example: http://12.34.56.78:8090/create-realm)
  3. Ensure that your Authorization is set
  4. Set the request body type to "x-www-form-urlencoded"
  5. Add the following form fields:
    • id The name of your realm.
    • password The password for connecting as the realm at the login server.
    • address The hostname of your realm where players will connect to. This should not be localhost but a public host name or ip if you want players to connect to it over the internet, but for testing or development 127.0.0.1 or localhost are fine
    • port The port where the realm server will accept incoming client connections. By default, the realm config uses port 8129 but you can change this in your realm servers config file.

Here is a sample screenshot of postman: image

If everything is okay, you should get HTTP 200 as a response. You are now ready to connecta realm to your login server!

Realm authentication

In order for the realm to authenticate with the login server, the realm config wants a hash used as the password. Your realm config should have a section like this:

realmConfig = 
(
	loginServerAddress = "12.34.56.78"
	loginServerPort = 6279
	realmName = "MYREALM"
	realmPasswordHash = "3E08BF63BE91F19EBE253C9519B159FD068954D7"
)

Now you might ask yourself what this hash is and how it is built.-Simply said: The hash is: HEX(SHA1("REALMNAME:PASSWORD")) It is important that you enter the realmname and the password in the hash in all uppercase letters.