Command Line Arguments and Config file

Command line arguments are used to start various systems that can run on both the server and client. You can also pass your own arguments to solve your tasks. To use your own arguments, you need to do the following:

Create a shortcut of your executable file

Open the shortcut properties with the right mouse button and in the Shortcut section in the Target property, you can see the specified path to the executable file. You must specify command line arguments immediately after this path. If the file path is specified in quotation marks, the command line arguments must be specified immediately after the closing quotes.

For example:

The example above shows a command that helps you start the master server automatically. Do not forget to specify value after it. Next comes the IP address of the master server with the specified value, and the last parameter is the port that the master server will listen to.

That's it!

Start the master server using the created shortcut and you will see the parameters you specified earlier in the console.

Access to values

You can access command-line arguments via the Mst.Args class. For example:

var port = Mst.Args.AssignedPort;

Mst.Args.Names - contains the exact names of all command-line arguments. For example:

// -mstMasterPort
var portArgName = Mst.Args.Names.MasterPort;

Checking whether arguments are available, use default value

// If master port is provided via cmd arguments
if (Mst.Args.IsProvided(Mst.Args.Names.MasterPort))
{
    serverPort = Mst.Args.MasterPort;
}

// If master IP is provided via cmd arguments and uses default value if arg is not provided
serverIP = Mst.Args.AsString(Mst.Args.Names.MasterIp, serverIP);

Using custom command line arguments

As mentioned earlier, you can use your own command-line arguments. Let's say you created your own command-line argument with the required value.

./Build -myMagicNumber 42

if (Mst.Args.IsProvided("-myMagicNumber"))
{
    // Extract integer value
    var number = Mst.Args.AsInt("-myMagicNumber");

    // Extract string value
    var str = Mst.Args.AsString("-myMagicNumber");

    // Extract bool value
    var b = Mst.Args.AsBool("-myMagicNumber");
}

Below is a list of console commands available in the framework. This list will change depending on updates.

Команда API(Mst.Args) Default value Description
-mstStartMaster StartMaster true/false Starts master server
-mstStartSpawner StartSpawner true/false Starts spawner server
-mstStartClientConnection StartClientConnection true/false Starts connection to server
-mstMasterPort MasterPort 5000 Use this cmd to setup master server connection port
-mstMasterIp MasterIp 127.0.0.1 Use this cmd to setup master server connection IP address
-mstSpawnTaskId SpawnTaskId Specified by spawner when starting room process Use this cmd to setup spawned process task ID
-mstSpawnTaskUniqueCode SpawnTaskUniqueCode Specified by spawner when starting room process Use this cmd to check if there's no tampering with spawned processes
-mstRoomIp RoomIp 127.0.0.1 Use this cmd to setup IP address of the spawned room server
-mstRoomPort RoomPort 7777 Use this cmd to setup port of the spawned room server
-mstWebPort WebPort 5056 Use this cmd to setup port of the web server
-mstRoomDefaultPort RoomDefaultPort 1500 Use this cmd if you want a spawner to start creating room ports from your own specific value
-mstRoomIsPrivate RoomIsPrivate true/false Use this cmd to setup server room as private or not
-mstRoomName RoomName Created automatically when room starts Use this cmd to setup server room name
-mstRoomPassword RoomPassword empty value "" Use this cmd to setup server room password
-mstRoomMaxConnections RoomMaxConnections 10 Use this cmd to setup the max number of connections of the spawned room server
-mstRoomExe RoomExecutablePath empty value "" Use this cmd to setup the path to room server executable file that you need to spawn
-mstRoomRegion RoomRegion International Use this cmd to setup the region, to which the spawner belongs
-mstUseWebSockets WebGl true/false Use this cmd to setup WebSockets mode on room server if you use WebGL version of client this feature works only is you server supports web sockets
-mstLoadScene LoadScene empty value "" Send this cmd to load room gameplay scene or another one when connected to room server
-mstDbConnectionString DbConnectionString empty value "" Use this cmd if youwant to connect to you database with some connection string
-mstLobbyId LobbyId Created automatically when room starts Id of the lobby, for which the process was spawned
-mstDontSpawnInBatchmode DontSpawnInBatchmode true/false Use this command to override SpawnerBehaviour.spawnInBatchmode check box
-mstMaxProcesses MaxProcesses 0 Use this cmd to setup the max number of processes the spawner can spawn
-mstAppKey ApplicationKey cannot be empty Defines an application key
-mstUseSecure UseSecure true/false Defines whether or not to use secure connection SSL/TLS
-mstCertificatePath CertificatePath empty value "" Defines path to certificate
-mstCertificatePassword CertificatePassword empty value "" Defines password for certificate
-mstUseDevMode UseDevMode true/false Defines whether or not to use development mode. May be useful for debugging

You can also define all command line arguments in application.cfg file. This file will be created automatically in root directory when application starts, but you can create it manually. To use cmd args in this file you are required to set up each command per line. Instead of space use "=" to define value of each command.

-mstUseSecure=true
-mstCertificatePath=...\MasterServer.pfx
-mstCertificatePassword=qwerty
-mstWebPort=5059