-
Notifications
You must be signed in to change notification settings - Fork 1
crossfire
Namazu Crossfire provides a complete foundation for cross-platform multiplayer. It handles session discovery, matchmaking, and connection signaling, making it easy to establish direct or relayed peer connections between players. Crossfire builds on open standards like WebRTC to ensure compatibility across diverse runtimes, from native builds to browsers.
Developers can use Crossfire alongside other Elements such as Identity, Data, and Cloud Functions to deliver seamless real-time multiplayer experiences.
See: Namazu Crossfire
This function these are the functions in the Crossfire module:
- elements_crossfire_set_identity
- elements_crossfire_connect
- elements_crossfire_disconnect
- elements_crossfire_find_match
- elements_crossfire_join_match
- elements_crossfire_leave_match
- elements_crossfire_open_match
- elements_crossfire_close_match
- elements_crossfire_end_match
- elements_crossfire_send_string_relay
- elements_crossfire_send_string_broadcast
- elements_crossfire_send_binary_relay
- elements_crossfire_send_binary_broadcast
- elements_crossfire_is_socket_open
- elements_crossfire_is_ready
- elements_crossfire_is_host
- elements_crossfire_get_participants
- elements_crossfire_get_match_id
- elements_crossfire_events_on_connected_callback
- elements_crossfire_events_on_connection_error_callback
- elements_crossfire_events_on_matched_callback
- elements_crossfire_events_on_signal_callback
- elements_crossfire_events_on_control_callback
- elements_crossfire_events_on_error_callback
- elements_crossfire_events_on_disconnected_callback
- elements_crossfire_events_on_unknown_callback
- elements_crossfire_events_on_phase_changed_callback
This function sets the Crossfire identity (profile, session key) used for matchmaking.
Syntax:
elements_crossfire_set_identity(_profile_id, _session_key)
| Argument | Type | Description |
|---|---|---|
| _profile_id | String | The Elements profile ID for this client. |
| _session_key | String | The session key obtained from the Elements REST API. |
Returns:
N/A
This function opens the WebSocket connection to Crossfire and enters the HANDSHAKE phase.
Syntax:
elements_crossfire_connect()
Returns:
True if the async connect request was started, false if already connected.
This function closes the Crossfire WebSocket connection and resets the client phase to DISCONNECTED.
Syntax:
elements_crossfire_disconnect()
Returns:
N/A
This function sends a FIND handshake to start matchmaking on the current connection.
Syntax:
elements_crossfire_find_match(_configuration)
| Argument | Type | Description |
|---|---|---|
| _configuration | String | The matchmaking configuration name or ID. |
Returns:
True if the message was sent, false if phase/identity/handshake state is invalid.
This function sends a JOIN handshake to rejoin a known match by its match ID.
Syntax:
elements_crossfire_join_match(_match_id)
| Argument | Type | Description |
|---|---|---|
| _match_id | String | The match ID to rejoin. |
Returns:
True if the message was sent, false if phase/identity/handshake state is invalid.
This function sends a LEAVE control message to leave the current match.
Syntax:
elements_crossfire_leave_match()
Returns:
True if the message was sent, false otherwise.
This function sends an OPEN control message to allow new participants to join the match.
Syntax:
elements_crossfire_open_match()
Returns:
True if the message was sent, false otherwise.
This function sends a CLOSE control message to prevent new participants from joining the match.
Syntax:
elements_crossfire_close_match()
Returns:
True if the message was sent, false otherwise.
This function sends an END control message to terminate the current match.
Syntax:
elements_crossfire_end_match()
Returns:
True if the message was sent, false otherwise.
This function sends a direct STRING_RELAY to a specific participant in the match.
Syntax:
elements_crossfire_send_string_relay(_recipient_profile_id, _text, _lifecycle)
| Argument | Type | Description |
|---|---|---|
| _recipient_profile_id | String | The profile ID of the target participant. |
| _text | String | The string payload to send. |
| _lifecycle | String | The lifecycle for this message ("ONCE", "SESSION", or "MATCH"). Defaults to "ONCE". |
Returns:
True if the message was sent, false otherwise.
This function broadcasts a STRING_BROADCAST message to all other participants in the match.
Syntax:
elements_crossfire_send_string_broadcast(_text, _lifecycle)
| Argument | Type | Description |
|---|---|---|
| _text | String | The string payload to broadcast. |
| _lifecycle | String | The lifecycle for this message ("ONCE", "SESSION", or "MATCH"). Defaults to "ONCE". |
Returns:
True if the message was sent, false otherwise.
This function sends a direct BINARY_RELAY to a specific participant using a base64-encoded buffer.
Syntax:
elements_crossfire_send_binary_relay(_recipient_profile_id, _buffer, _lifecycle)
| Argument | Type | Description |
|---|---|---|
| _recipient_profile_id | String | The profile ID of the target participant. |
| _buffer | Buffer | The buffer whose contents will be relayed as base64. |
| _lifecycle | String | The lifecycle for this message ("ONCE", "SESSION", or "MATCH"). Defaults to "ONCE". |
Returns:
True if the message was sent, false otherwise.
This function broadcasts a BINARY_BROADCAST message to all other participants using a base64-encoded buffer.
Syntax:
elements_crossfire_send_binary_broadcast(_buffer, _lifecycle)
| Argument | Type | Description |
|---|---|---|
| _buffer | Buffer | The buffer whose contents will be broadcast as base64. |
| _lifecycle | String | The lifecycle for this message ("ONCE", "SESSION", or "MATCH"). Defaults to "ONCE". |
Returns:
True if the message was sent, false otherwise.
This function returns whether the underlying WebSocket is currently open (HANDSHAKE or SIGNALING).
Syntax:
elements_crossfire_is_socket_open()
Returns:
True if the socket is open, false otherwise.
This function returns whether the Crossfire client is fully ready (SIGNALING phase) for messaging.
Syntax:
elements_crossfire_is_ready()
Returns:
True if the client is in SIGNALING phase, false otherwise.
This function returns whether this client is currently the host of the match.
Syntax:
elements_crossfire_is_host()
Returns:
True if this client is the host, false otherwise.
This function returns a struct of all the current participants in the match (profile_id : { connected }).
Syntax:
elements_crossfire_get_participants()
Returns:
This function returns the ID of a previously joined match (useful for reconnecting).
Syntax:
elements_crossfire_get_match_id()
Returns:
This function sets the callback invoked when the WebSocket successfully connects.
Syntax:
elements_crossfire_events_on_connected_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call on successful socket connection. |
Returns:
N/A
This function sets the callback invoked when the WebSocket connection fails.
Syntax:
elements_crossfire_events_on_connection_error_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call on connection error. |
Returns:
N/A
This function sets the callback invoked when a MATCHED message is received and the match is assigned.
Syntax:
elements_crossfire_events_on_matched_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call when the client receives MATCHED. |
Returns:
N/A
This function sets the callback invoked for signaling messages (SIGNAL_*, CONNECT/DISCONNECT, STRING/BINARY relays/broadcasts).
Syntax:
elements_crossfire_events_on_signal_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call for incoming signal messages. |
Returns:
N/A
This function sets the callback invoked for incoming control messages (LEAVE, OPEN, CLOSE, END) if sent by the server.
Syntax:
elements_crossfire_events_on_control_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call for incoming control messages. |
Returns:
N/A
This function sets the callback invoked when an ERROR message is received from the server.
Syntax:
elements_crossfire_events_on_error_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call for protocol error messages. |
Returns:
N/A
This function sets the callback invoked when the WebSocket disconnects.
Syntax:
elements_crossfire_events_on_disconnected_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call on socket disconnection. |
Returns:
N/A
This function sets the callback invoked when an unrecognized message type is received.
Syntax:
elements_crossfire_events_on_unknown_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call for unknown message types. |
Returns:
N/A
This function sets the callback invoked whenever the client's internal CF_PHASE changes.
Syntax:
elements_crossfire_events_on_phase_changed_callback(_callback)
| Argument | Type | Description |
|---|---|---|
| _callback | Function | The function to call when the connection phase is updated. |
Returns:
N/A
GameMaker 2026
- Application
- Auth
- Auth Scheme
- Blockchain
- Codegen
- Deployment
- Elements
- Elm
- Followee
- Follower
- Friend
- Health
- Index
- Inventory
- Invite
- Ios
- Item
- Large Object
- Large Object Mp
- Leaderboard
- Meta
- Metadata
- Metadata Spec
- Mission
- Mock Session
- Multi Match
- Notification
- Oidc
- Product
- Profile
- Progress
- Rank
- Receipt
- Reward Issuance
- Save Data
- Schedule
- Score
- Session
- Signup
- Steam
- User
- Verify
- Version