Servers
There are some servers implementations and Build profiles in SimpleNet/ServerBuilds
. This will be reworked.
Server dev scene
Build path of the development scene.
Configs
- With graphics, windowed 800x800
- developer
- allow debugging
- connect with profiler
- define symbols + WONDERLAND_SERVER WONDERLAND_SOCKETSTATS
- run in background
- resizableWindow: false
- forceSingleInstance: true
- allowFullscreenSwitch: false
- stripping level: low
Server release scenes
Release configs.
- PathReleaseScenes: The base path
- ReleaseScenes: List of server scenes (selectable in dashboard)
- MasterReleaseScene: List of master server scenes (selectable in dashboard)
- DataReleaseScene: List of data server scenes (selectable in dashboard)
Configs
- Without graphics
- define symbols + WONDERLAND_SERVER UNITY_SERVER
- run in background
- stripping level: medium
- stripUnusedMeshComponents
- SetPreloadedAssets(new Object[0])
- ShaderHeadlessModeBuildProcessor.Enabled = true -> removes all shaders
Server configs
Port
: Server port; -1 = disabledWPort
: Webserver port; -1 = disabledMinPlayerNumber
: If player number <, close serverMaxPlayerNumber
: Player refused if connected peers >.AutoCloseApplication
: Application is automatically closed if player number < MinPlayerNumber.InstanceRemoveInterval
: Delay to remove a scene instance.Password
: Password to connect to this server.PingShareLoopInterval
: Interval between each share of peers latencyWaitForPeers
: Auto kill server if player number < MinPlayersNumber after its creation; -1 = wait foreverFPS
: Frames per seconds limitAutoDestroyGameObject
: Replace application closing with a GameObject destroyDataServerAddress
: Address of the data server (optional)DataServerPort
: Port of the data server (optional)DataServerPsw
: Password of the data server (optional)
Basic server
Script:
SimpleNet/Server/Server.cs
This behaviour initializes a server on the configured port. Hosts one party.
It is used in two scenes :
SimpleNet/ServerDev/ServerDev
SimpleNet/ServerRel/Server
ServerDev
is a dev version using stats.
In dev, use localhost. You can directly set a NetManager to localhost with same port and password. It accepts the user and allows scenes instancing. Basically in the dev scene, the application is not automatically close if no player is connected.
ServerWithConfigFile
Script:
SimpleNet/ServerRel/ServerWithConfigFile.cs
Loads a json file with the config and starts the server after.
The file must be in the root folder (beside the exe) and called server_config.json
.
{
"Port": 5882,
"WPort": -1,
"MinPlayersNumber": 1,
"MaxPlayersNumber": 7,
"AutoCloseApplication": true,
"InstanceRemoveInterval": 1,
"Password": "MY STRONG PASSWORD",
"PingShareLoopInterval": 2,
"WaitForPeers": 10,
"FPS": 60,
"DataServerAddress": "",
"DataServerPort": -1,
"DataServerPsw": "****"
}
ServerWithConfigCmd
Script:
SimpleNet/ServerRel/ServerWithConfigCmd.cs
LikeServerWithConfigFile
but gets config in cmd.
Wonderland_WS.exe -Port 5882 -WPort -1 -MinPlayersNumber 1 -MaxPlayersNumber 7 -AutoCloseApplication true -InstanceRemoveInterval 1 -Password *** -PingShareLoopInterval 2 -WaitForPeers 10 -FPS 60
ServerMultiple
Script:
SimpleNet/ServerRel/ServerMultiple.cs
ServerMultiple can receive a TCP command to instanciate server. All instantiated servers have a port number equals to server port + first free port.
- If
WPortValueAdd != -1
, it enables websocket. The game port is equals toinstance port + WPortValueAdd
. WSOnly
: Websocket only
config file
{
"Port": 5882,
"MinPlayersNumber": 1,
"MaxPlayersNumber": 7,
"WPortValueAdd": -1,
"WSOnly": false,
"AutoCloseApplication": true,
"InstanceRemoveInterval": 1,
"Password": "MY STRONG PASSWORD",
"PingShareLoopInterval": 2,
"WaitForPeers": 30,
"FPS": 60,
"DataServerAddress": "",
"DataServerPort": -1,
"DataServerPsw": "****"
}
Master server use this server.
Creation request
SimpleNetMasterCmds.CreateServer
without arguments.
This request returns the port and a strong random passord.
var response = await server.Peer.Send(SimpleNetMasterCmds.CreateServer, _cloud.DefaultNetwork, PacketsBatcher.Priority.immediate);
var port = response.Read<int>();
var pass = response.Read<string>();
if (port > 0 && !string.IsNullOrEmpty(pass)) {
//
}
Port list request
SimpleNetMasterCmds.GetPortList
without arguments.
Returns a list of used ports. (use this to update your active server list)
var response = await serv.Peer.Send(SimpleNetMasterCmds.GetPortList, _cloud.DefaultNetwork);
if (response != null) {
var portList = response.Read<List<ushort>>();
}
Create your own
Use the examples to understand to create your own scripts and scenes.