Skip to content

Message

Jirka Dell'Oro-Friedl edited this page Sep 18, 2022 · 2 revisions

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.

command

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.

idRoom

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.

route

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.

idTarget

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.

content

An associative array of the actual content of the message. A message using a command usually doesn't carry any additional content.

Clone this wiki locally