Skip to content

In‐band

Mike J. Renaker / "MikeDEV edited this page Dec 14, 2024 · 1 revision

In-band

The in-band WebRTC data channel subprotocol that CL5 utilizes is defined as clomega (RTCDataChannel.protocol property).

All messages are JSON-encoded and follow a similar schema to CL5's signaling spec.

If the lobby has server-side relay enabled, a new peer called relay will connect. To relay a message, specify a recipient while sending a message to the relay.

{
	opcode: string, // See in-band opcodes
	payload: any, // Message data
    recipient: string, // Requires server-side relay to be enabled by the lobby host. This argument will be used by the "relay" peer.
    origin: string, // Do not set manually; It is set by the "relay" peer. Returns the player ID that the message was relayed from.
}

All opcodes

opcode is a string that represents one of the following message states:

Opcode Description
G_MSG An implied insecure multicast message.
G_VAR An implied insecure multicast variable.
G_LIST An implied insecure multicast networked list.
P_MSG An implied secure unicast message.
P_VAR An implied secure unicast variable.
P_LIST An implied secure unicast networked list.

Encryption support

CL5 utilizes ECDH-P256-AES-GCM cryptography. Public keys are based on SPKI-BASE64. As specified in the signaling protocol spec, this is an optional (but recommended) feature to specify when configuring your session as a lobby host or peer. If a public key wasn't specified during setup, it is not recommended to use P_MSG, P_VAR or P_LIST.

Opcode-specific syntax

G_MSG

G_MSG is an implied insecure broadcast message, intended for sharing messages to all peers.

{
	opcode: "G_MSG",
	payload: { ... }, // Message data
}

G_VAR

G_VAR is an implied insecure broadcast message, intended for sharing variables to all peers.

{
	opcode: "G_VAR",
	payload: {
		name: string, // Name of the variable to update.
		data: { ... },
	},
}

G_LIST

G_LIST is an implied insecure broadcast message, intended for sharing networked lists to all peers.

{
	opcode: "G_LIST",
	payload: {
		name: string, // Name of the networked list to update.
		data: [...],
	},
}

P_MSG

P_MSG is an implied secure unicast message, intended for sending messages to specific peers. Providing a public key to the signaling server on setup before sending this message is required for security.

{
	opcode: "P_MSG",
	payload: { ... }, // Should be encrypted with peer's public key.
}

P_VAR

P_VAR is an implied secure unicast message, intended for sending variables to specific peers. Providing a public key to the signaling server on setup before sending this message is required for security.

{
	opcode: "P_VAR",
	payload: {
		name: string, // Name of the variable to update.
		data: { ... }, // Should be encrypted with peer's public key.
	}
}

P_LIST

P_LIST is an implied secure unicast message, intended for sending networked lists to specific peers. Providing a public key to the signaling server on setup before sending this message is required for security.

{
	opcode: "P_LIST",
	payload: {
		name: string, // Name of the networked list to update.
		data: [ ... ], // Should be encrypted with peer's public key.
	}
}
Clone this wiki locally