DarkRift Quickstart This quickstart should guide you through installing and running your DarkRift server. If you already have a copy of a DarkRift Server skip to the Booting section. Downloading 1. Open the Unity asset store. 2. Search for DarkRift and select the item labelled “DarkRift – Free” (the publisher will be DarkRift) 3. Download and install the package. 4. Extract the “DarkRift Server” zipped folder to your desired location. Running DarkRift servers are easy to get going, simply double click DarkRiftServer.exe from the DarkRift Server folder and wait till it says “Server mounted...”. Architecture Standalone DarkRift servers are made up of the server, plugins and the config. The following block diagram illustrates how the server executable interacts with the other parts exposed. Clients Server Plugins are loaded at startup only (currently). The server must be restarted for plugins to be discovered. Plugins Config is only accessed when the server is loaded so things like ports cannot be changed while running. Config Internally DarkRift handles data in 2 halves: Data Pump The first section is the data pump. This runs in a background thread and simply iterates over all connections and moves data from the sockets to internal buffers and creates thread pool tasks for each message. This thread is important to stop data overflow on the sockets, on older architectures we found that by sending too much data to the server would sometimes cause the socket to overflow because the workers were spending lots of time in plugins and it built up too far. Therefore this thread’s primary function is to move data off the sockets as fast as possible and then create a task for each so that they can processed. Thread Pool The system’s thread pool is where most of the work occurs. Each item transferred by the DataPump is processed by a thread, sent to plugins and then distributed out to clients as needed. First it decodes the header on the message, if this validates it is passed to the onData plugin event, if any plugins are using onDataDecoded it then unserialised the data and executes and event registered. Next it re-encodes the header (and if needed the body) and rebuilds the byte stream for the network and then passes it to the distributor. This, if a plugin is not overriding it, simply looks at the header and decides whether to send it to a single client, all clients, all clients but sender or even just to give it to another plugin via onServerMessage. This covers the majority of the network processing, there are other aspects like ID allocation, plugin loading etc. but it is not worth documenting them here because the chances of their workings affecting you use are likely minimal. Commands Commands are used in Darkrift to control the server and plugins from the console, they allow administrators to perform tasks easily. There aren’t many commands at the moment but more are to come with updates. ListCommands Desc: Lists all the commands available. This simply displays a list of the commands that can be executed onto the console. Stop Desc: Stops the server and closes it safetly. This instructs the server to close all connections and shutdown safely, there’s nothing wrong with just hitting the X (if you’re using the GUI this happens automatically) it’s just a bit safer and ensures the plugins shutdown safely too. Kick [ID] Desc: Forces a client of id (parameter) to disconnect. This causes the instant disconnection of the specified client from the server. Kickall Desc: Forces all clients to disconnect. This disconnects all the clients from the server. LogPerformance Desc: Outputs the current performance stats to screen. This logs the server’s performance stats to the console. You can use this to check up on lag etc. when building or installing plugins. The Configuration File In the same directory as the server executable there is a file called settings.cnf; this is the main configuration file where you can change settings about the server in a standard text editor (like notepad). Configuration files are written using key-value pairs each on a new line; the pairs are separated using colons. settings.cnf contains the server’s main properties: Port – This is the port that the server listens on and operates on (default 4296) LogData – Tells the server whether to output a log of data passing through the server. Due to having to write to the console this can add around 6ms onto the process time in the server so only use it for debugging (default False). MaxConnections – The maximum connections you want this server to allow, any others will be rejected. Plugins Plugins are key to authorative DarkRift servers, they allow the server to dynamically respond to data. Plugin files are simply .dll files written specifically as plugins. To install them you simply need to move the .dll file into the Plugins folder and restart the server. You should see “Loaded: <Plugin name>: V<version>” on the console confirming it loaded correctly. If you want more information about writing plugins check out the Server Plugin Tutorial! Events This is a summary of the events the server calls in order along with the conditions under which they are called. Called during the startup of the server. Called when a new client connects to the server. The list of connections DarkRift stores is updated between these 2 events so DarkRift.GetAllConnections will only include the new connection in onPostPlayerConnect. Called when data is received at the server. Data can be decoded in onData using NetworkMessage.DecodeData(), onDataDecided already has data deserialized but is now obsolete and shouldn’t be used. Called to allow your plugins to override the automatic distribution methods. If the message is a server message then this will be called to allow the server to process it, all other messages will bypass this. PluginManager.onPluginsLoaded ConnectionService.onPlayerConnect ConnectionService.onPostPlayerConnect ConnectionService.onData ConnectionService.onDataDecoded ConnectionService.onDistribute ConnectionService.onServerMessage Logs Logs are fairly simple, everything put on a console (plus a little more sometimes) is also written to a file with their timestamp. These files are under the Logs directory under the date the server was started; every time you run the server a new file is created and then all data is written there. If you’re ever seeking assistance from us, send us the log files detailing the error, it’ll be a lot easier for us to identify the problem!