Skip to content

In‐band

Mike J. Renaker / "MikeDEV edited this page Dec 18, 2024 · 2 revisions

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.
    channel: string, // If you are sending a message to the server-side relay, this will be specified for tracking purposes on the client side.
}

All opcodes

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

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

Opcode-specific syntax

G_MSG

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

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

G_VAR

G_VAR is an implied 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 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 unicast message, intended for sending messages to specific peers.

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

P_VAR

P_VAR is an implied unicast message, intended for sending variables to specific peers.

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

P_LIST

P_LIST is an implied unicast message, intended for sending networked lists to specific peers.

{
	opcode: "P_LIST",
	payload: {
		name: string, // Name of the networked list to update.
		data: [ ... ],
	}
}
Clone this wiki locally