-
Notifications
You must be signed in to change notification settings - Fork 27
Message
The messages sent and received with FudgeNet are JSON-strings structured as follows:
{ command?: COMMAND, idRoom?: string, route?: ROUTE, idTarget?: string, content?: { [key: string]: any }
All entries are optional. Additionally, a message contains information defined by FudgeNet about the source of the message, the timestamps of the sender and the server.
Triggers predefined functions on the client or server side for setting up connections or establishing rooms etc. Messages transporting data about gamestates usually do not specify a command. However, it's possible to extend FudgeServer or FudgeClient and to define additional commands.
When creating a room for clients to connect with, FudgeServer generates an id for it. Using this id, messages can be broadcast to all clients connected to that room e.g.
Defines the route for the message to take, in conjunction with idTarget
. Depending on the values given, a message may be sent to a specific client directly or via the server, broadcast to all clients to the server only etc.
Specifies the target to send the message to. If omitted, the message may be broadcast to all clients in the same room or to the server only depending on the value of route
.
An associative array of the actual content of the message. A message using a command
usually doesn't carry any additional content.