Aller au contenu

gdmp.net

Ce contenu n’est pas encore disponible dans votre langue.

Messages between the server script and the client scripts. A channel is 1..23 characters of A-Z a-z 0-9 _ . : -; names starting with gdmp. are GDMP’s own. Data is any JSON value, at most 1600 bytes as JSON.

Call What it does
client: send(channel, data) → bool to the server script
server: send(playerId, channel, data) → bool to one player’s client script
server: broadcast(channel, data) → bool to every player
onMessage(cb) cb({from, channel, data}); from = the player id (0 = the server)

Rates: server → clients ≤ 120 messages / s; each client → server ≤ 30 / s.

The declarations from the GDMP types (namespace GDMP), comments included:

/** A channel: 1..23 of `A-Z a-z 0-9 _ . : -`. Names starting with `gdmp.` are GDMP's own. */
type Channel = string;
interface NetMessage { readonly from: PlayerId; readonly channel: Channel; readonly data: Received }
interface NetServer extends NetCommon {
/** To one player's client script. At most 1600 bytes as JSON. */
send(playerId: PlayerId, channel: Channel, data: Json): boolean;
broadcast(channel: Channel, data: Json): boolean;
}
interface NetClient extends NetCommon {
/** To the server script. At most 1600 bytes as JSON, 30 a second. */
send(channel: Channel, data: Json): boolean;
}