This is a Socket.IO relay server to facilitate communication between Unity clients and web browsers.
Each client (Unity or web) must use the same teamHash to be able to communicate with each other. \
In this example we use the teamHash 'd42dd7b40d320c25c2c94aea82199934', but you should change this to a unique hash for your team! \
Listen for "messageToUnity" events. Read the data object which looks like this: \
{
teamHash: 'd42dd7b40d320c25c2c94aea82199934',
content: {
/* The actual message content sent from the web browser. */
}
}
Send messages to web browsers by emitting "messageFromUnity" events with a data object like this: \
{
teamHash: 'd42dd7b40d320c25c2c94aea82199934',
content: {
action: 'someEventName',
data: { /* any data you want to send to the web browser */ }
}
}
Listen for "messageToBrowser" events. Read the data object which looks like this: \
{
teamHash: 'd42dd7b40d320c25c2c94aea82199934',
content: { /* The actual message content sent from Unity. */ }
}
Send a message to Unity clients by emitting a "messageFromBrowser" event with a data object like this: \
{
teamHash: 'd42dd7b40d320c25c2c94aea82199934',
content:
{
action: 'someEventName',
data: { /* any data you want to send to the web browser */ }
}
}
To disconnect all clients associated with a specific teamHash, either Unity or web clients can emit a "disconnectAll" event with this data object: \
{
teamHash: 'd42dd7b40d320c25c2c94aea82199934'
}