Unity Multi by 2-REC - 5


Server-client for Unity multiplayer projects (using SpaceBrew)

Unity 2018.3.6f1Unknown LicenseUpdated 55 days agoCreated on April 18th, 2019
Go to source



Server-client for Unity multiplayer projects.

It uses the SpaceBrew* toolkit for the server management and the communications between it and the clients.
For the interaction with Unity, the project is based on the spacebrewUnity library.

The SpaceBrew toolkit has been integrated in the project, and its execution can be managed by the Unity project directly (using an embedded Node.js*).

(*) The “SpaceBrew” and “Unity Node.js” projects are included in the repository as normal files (not as dependencies/submodules). The corresponding versions can be determined from the timestamps of the last respective commits. In order to use the latest version, the projects should be downloaded separately. Beware however that the compatibility might not be 100% guaranteed.
It is possible to use external SpaceBrew server and Node.js depending on the used prefabs and their configuration (see below in the “Components” section).


It is composed of components (prefabs).

  • 3 different types:
    • Client: …
    • Admin: …
    • Server: …


Here is a description of the messages sent from the clients to the server.


The first message a client sends is a “Remove” message, to remove itself from the serrver tables and make sure everything is clean before going further.

{ "remove": [ { "name": "UnitySpacebrewClient", "remoteAddress": "" } ], "targetType": "admin" }


Every client sends a “Config” message to provide required information about its configuration.
The messages contain the following information:

  • “name”: Name of the client.
  • “description”: A short description of the client.
  • “publish”: List of the client’s publishers.
    => For each publisher, specific inforamtion is provided:
    • “name”: Name used to connect to a subscriber from another client.
    • “type”: Type of its data (“boolean”, “range” or “string”).
    • “default”: The default value of its data.
  • “subscribe”: List of the client’s subscribers.
    => For each subscriber, specific inforamtion is provided:
    • “name”: Name used to connect to a publisher from another client.
    • “type”: Type of its data (“boolean”, “range” or “string”).
  • “remoteAddress”: The IP address of the client.
  • Some additional options can be provided (see the official SpaceBrew doc for details)

{ "config": { "name":"UnitySpacebrewClient", "description":"Basic Unity Client for Spacebrew", "publish": { "messages": [ {"name":"pubBool","type":"boolean","default":""}, {"name":"pubRange","type":"range","default":""}, {"name":"pubString","type":"string","default":""} ] }, "subscribe": { "messages": [ {"name":"subBool","type":"boolean"}, {"name":"subRange","type":"range"}, {"name":"subString","type":"string"} ] }, "remoteAddress":"" }, "targetType":"admin" } "options":{},


A route message can be sent to create a link between a publisher and a subscriber.
It provides the descritpion for a publisher of a client and a subscriber of another client.

{ "route": { "type":"add", "publisher": {"clientName":"UnitySpacebrewClient","name":"pubString","type":"string","remoteAddress":""}, "subscriber": {"clientName":"UnitySpacebrewClient2","name":"subString","type":"string","remoteAddress":""} }, "targetType":"admin" }

Data Message

When a link between a publisher and a subscriber is established, communication can be done by sending messages.

  • “name”: Name of the publisher.
  • “type”: Type of the message data.
  • “value”: Data of the message. It must be of the specified type.
  • “clientName”: The name of the cilient sending the message.

The content of the messages is obviously specific to each application, and can be anything as long as it respects the provided type.

{ "message": { "name":"subString", "type":"string", "value":"{\"SRC\":\"client\", \"position\":{\"x\":\"0\", \"y\":\"0\", \"z\":\"0\"}, \"direction\":{\"x\":\"0\", \"y\":\"0\", \"z\":\"100\"}}", "clientName":"UnitySpacebrewClient" } }

Show all projects by 2-REC