Skip to Content
defold-typescript libraries
heroiclabsnakama-defold

heroiclabs/nakama-defold/nakama.socket

Realtime Nakama socket: chat channels, matches, matchmaking, parties, status and their event listeners.

  • GitHub: heroiclabs/nakama-defold — pinned to v3.4.0
    1. Pick a release from heroiclabs/nakama-defold releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as socket from "nakama.socket"

Functions

create(client: unknown): Socket

Creates a realtime socket for a client, and binds every other export of this module onto it. nakama.create_socket is the same call reached through the core module.

Parameters

  • client: unknown — A client created with nakama.create_client.

Returns

  • Socket

connect(socket: Socket, callback?: (success: boolean, error?: string) => void): unknown

Opens the socket's websocket connection to the server.

Parameters

  • socket: Socket — A socket created with create.
  • callback?: (success: boolean, error?: string) => void — Receives whether the connection succeeded, and the error if it did not.

Returns

  • unknown — The result, when no callback is given.

send(socket: Socket, message: unknown, callback?: (message: unknown) => void): unknown

Sends a prepared message table on the socket. The calls below build their own message tables and pass them through here.

Parameters

  • socket: Socket — A socket created with create.
  • message: unknown — The message table to send.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

on_disconnect(socket: Socket, fn: () => void)

Registers the function to call when the connection drops. It is called with no arguments, and replaces the socket's bound on_disconnect method.

Parameters

  • socket: Socket — A socket created with create.
  • fn: () => void — Called on disconnect.

channel_join(socket: Socket, target: string, type: number, persistence: boolean, hidden: boolean, callback?: (message: unknown) => void): unknown

Joins a chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • target: string — The room name, group id or user id to join, depending on type.
  • type: number — One of the CHANNELTYPE_* constants.
  • persistence: boolean — Store the channel's messages on the server.
  • hidden: boolean — Join without appearing in the channel's presence list.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

channel_leave(socket: Socket, channel_id: string, callback?: (message: unknown) => void): unknown

Leaves a chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • channel_id: string — The channel to leave.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

channel_message_send(socket: Socket, channel_id: string, content: string, callback?: (message: unknown) => void): unknown

Sends a message to a joined chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • channel_id: string — The channel to send to.
  • content: string — The message content, as a JSON string.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

channel_message_remove(socket: Socket, channel_id: string, message_id: string, callback?: (message: unknown) => void): unknown

Removes a message previously sent to a chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • channel_id: string — The channel the message is in.
  • message_id: string — The message to remove.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

channel_message_update(socket: Socket, channel_id: string, message_id: string, content: string, callback?: (message: unknown) => void): unknown

Replaces the content of a message previously sent to a chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • channel_id: string — The channel the message is in.
  • message_id: string — The message to update.
  • content: string — The replacement content, as a JSON string.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

match_data_send(socket: Socket, match_id: string, op_code: number, data: string, presences: unknown, reliable: boolean, callback?: (message: unknown) => void): unknown

Sends data to a joined match. The data is base64-encoded on the way out and decoded again for the receiving on_match_data listener.

Parameters

  • socket: Socket — A socket created with create.
  • match_id: string — The match to send to.
  • op_code: number — The application-defined operation code.
  • data: string — The payload.
  • presences: unknown — The presences to send to, or nil for everyone in the match.
  • reliable: boolean — Send over the reliable channel.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

match_create(socket: Socket, name: string | undefined, callback?: (message: unknown) => void): unknown

Creates a new authoritative-relayed match.

Parameters

  • socket: Socket — A socket created with create.
  • name: string | undefined — The match name, or nil to let the server generate one.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

match_join(socket: Socket, match_id: string | undefined, token: string | undefined, metadata: unknown, callback?: (message: unknown) => void): unknown

Joins a match by id, or by the token a matchmaker result carried. Exactly one of the two identifiers is set; the other is nil.

Parameters

  • socket: Socket — A socket created with create.
  • match_id: string | undefined — The match to join.
  • token: string | undefined — The match token, when joining a matchmaker result.
  • metadata: unknown — Metadata to present to the match's other members.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

match_leave(socket: Socket, match_id: string, callback?: (message: unknown) => void): unknown

Leaves a joined match.

Parameters

  • socket: Socket — A socket created with create.
  • match_id: string — The match to leave.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

matchmaker_add(socket: Socket, min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknown

Joins the matchmaker pool. The ticket the server returns is what matchmaker_remove cancels with, and a match arrives through on_matchmaker_matched.

Parameters

  • socket: Socket — A socket created with create.
  • min_count: number — The smallest acceptable match size.
  • max_count: number — The largest acceptable match size.
  • query: string — The matchmaker query to filter candidates by.
  • string_properties: unknown — This user's string properties, for other queries to match on.
  • numeric_properties: unknown — This user's numeric properties, for other queries to match on.
  • count_multiple: number — Only form matches whose size is a multiple of this.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

matchmaker_remove(socket: Socket, ticket: string, callback?: (message: unknown) => void): unknown

Leaves the matchmaker pool.

Parameters

  • socket: Socket — A socket created with create.
  • ticket: string — The ticket matchmaker_add returned.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_create(socket: Socket, open: boolean, max_size: number, callback?: (message: unknown) => void): unknown

Creates a party and makes this user its leader.

Parameters

  • socket: Socket — A socket created with create.
  • open: boolean — Let users join without a join request.
  • max_size: number — The largest number of members the party accepts.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_join(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknown

Joins a party, or requests to join one that is not open.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to join.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_leave(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknown

Leaves a party.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to leave.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_promote(socket: Socket, party_id: string, presence: unknown, callback?: (message: unknown) => void): unknown

Promotes a party member to leader.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party the member is in.
  • presence: unknown — The member's presence.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_accept(socket: Socket, party_id: string, presence: unknown, callback?: (message: unknown) => void): unknown

Accepts a pending join request, as party leader.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party the request is for.
  • presence: unknown — The requesting user's presence.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_remove(socket: Socket, party_id: string, presence: unknown, callback?: (message: unknown) => void): unknown

Removes a member from the party, or rejects a pending join request.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to remove from.
  • presence: unknown — The member's presence.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_close(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknown

Closes the party to new members and disbands it, as party leader.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to close.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_join_request_list(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknown

Lists the party's pending join requests.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to list requests for.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_matchmaker_add(socket: Socket, party_id: string, min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknown

Joins the matchmaker pool as a whole party, as party leader.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to match with.
  • min_count: number — The smallest acceptable match size.
  • max_count: number — The largest acceptable match size.
  • query: string — The matchmaker query to filter candidates by.
  • string_properties: unknown — The party's string properties, for other queries to match on.
  • numeric_properties: unknown — The party's numeric properties, for other queries to match on.
  • count_multiple: number — Only form matches whose size is a multiple of this.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_matchmaker_remove(socket: Socket, party_id: string, ticket: string, callback?: (message: unknown) => void): unknown

Takes the party back out of the matchmaker pool.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to cancel for.
  • ticket: string — The ticket party_matchmaker_add returned.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

party_data_send(socket: Socket, party_id: string, op_code: number, data: string, callback?: (message: unknown) => void): unknown

Sends data to every member of a party.

Parameters

  • socket: Socket — A socket created with create.
  • party_id: string — The party to send to.
  • op_code: number — The application-defined operation code.
  • data: string — The payload.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

status_follow(socket: Socket, user_ids: string, usernames: string, callback?: (message: unknown) => void): unknown

Subscribes to the status updates of the given users.

Parameters

  • socket: Socket — A socket created with create.
  • user_ids: string — The user ids to follow.
  • usernames: string — The usernames to follow.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

status_unfollow(socket: Socket, user_ids: string, callback?: (message: unknown) => void): unknown

Unsubscribes from the status updates of the given users.

Parameters

  • socket: Socket — A socket created with create.
  • user_ids: string — The user ids to unfollow.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

status_update(socket: Socket, status: string, callback?: (message: unknown) => void): unknown

Sets this user's status message, or clears it when the status is empty.

Parameters

  • socket: Socket — A socket created with create.
  • status: string — The status message to publish to followers.
  • callback?: (message: unknown) => void — Receives the server's response.

Returns

  • unknown — The response, when no callback is given.

on_channel_presence_event(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when someone joins or leaves a joined chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the channel presence event.

on_match_presence_event(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when someone joins or leaves a joined match.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the match presence event.

on_match_data(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when match data arrives. The payload is base64-decoded before the listener sees it.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the match data.

on_match(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when a match is created or joined.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the match.

on_matchmaker_matched(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when the matchmaker finds a match. Its token is what match_join takes.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the matchmaker result.

on_notifications(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when notifications arrive for this user.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the notifications.

on_party_presence_event(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when someone joins or leaves a joined party.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the party presence event.

on_party(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when a party is created or joined.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the party.

on_party_data(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when party data arrives.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the party data.

on_party_join_request(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when someone asks to join a party this user leads.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the join request.

on_party_leader(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when a party changes leader.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the new leader.

on_status_presence_event(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when a followed user comes online or goes offline.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the status presence event.

on_status(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when a followed user changes their status message.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the status.

on_stream_data(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when data arrives on a subscribed stream.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the stream data.

on_error(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when the server reports an error. Its code is one of the ERROR_* constants.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the error.

on_channel_message(socket: Socket, fn: (message: unknown) => void)

Registers the function to call when a message arrives on a joined chat channel.

Parameters

  • socket: Socket — A socket created with create.
  • fn: (message: unknown) => void — Receives the channel message.

Variables

CHANNELTYPE_UNSPECIFIED: 0

Unspecified channel type. The server treats it as a room.

CHANNELTYPE_ROOM: 1

A room anyone can join to chat in.

CHANNELTYPE_DIRECT_MESSAGE: 2

A private channel for one-to-one chat.

CHANNELTYPE_GROUP: 3

A channel for group chat.

ERROR_RUNTIME_EXCEPTION: 0

An unexpected result from the server.

ERROR_UNRECOGNIZED_PAYLOAD: 1

The server received a message it does not recognise.

ERROR_MISSING_PAYLOAD: 2

A message was expected but contains no content.

ERROR_BAD_INPUT: 3

Fields in the message have an invalid format.

ERROR_MATCH_NOT_FOUND: 4

The match id was not found.

ERROR_MATCH_JOIN_REJECTED: 5

The match join was rejected.

ERROR_RUNTIME_FUNCTION_NOT_FOUND: 6

The runtime function does not exist on the server.

ERROR_RUNTIME_FUNCTION_EXCEPTION: 7

The runtime function executed with an error.

Types

Socket

Socket.connect(callback?: (success: boolean, error?: string) => void): unknown

Parameters

  • callback?: (success: boolean, error?: string) => void

Returns

  • unknown

Socket.send(message: unknown, callback?: (message: unknown) => void): unknown

Parameters

  • message: unknown
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.on_disconnect(fn: () => void)

Parameters

  • fn: () => void

Socket.channel_join(target: string, type: number, persistence: boolean, hidden: boolean, callback?: (message: unknown) => void): unknown

Parameters

  • target: string
  • type: number
  • persistence: boolean
  • hidden: boolean
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.channel_leave(channel_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • channel_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.channel_message_send(channel_id: string, content: string, callback?: (message: unknown) => void): unknown

Parameters

  • channel_id: string
  • content: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.channel_message_remove(channel_id: string, message_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • channel_id: string
  • message_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.channel_message_update(channel_id: string, message_id: string, content: string, callback?: (message: unknown) => void): unknown

Parameters

  • channel_id: string
  • message_id: string
  • content: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.match_data_send(match_id: string, op_code: number, data: string, presences: unknown, reliable: boolean, callback?: (message: unknown) => void): unknown

Parameters

  • match_id: string
  • op_code: number
  • data: string
  • presences: unknown
  • reliable: boolean
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.match_create(name: string | undefined, callback?: (message: unknown) => void): unknown

Parameters

  • name: string | undefined
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.match_join(match_id: string | undefined, token: string | undefined, metadata: unknown, callback?: (message: unknown) => void): unknown

Parameters

  • match_id: string | undefined
  • token: string | undefined
  • metadata: unknown
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.match_leave(match_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • match_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.matchmaker_add(min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknown

Parameters

  • min_count: number
  • max_count: number
  • query: string
  • string_properties: unknown
  • numeric_properties: unknown
  • count_multiple: number
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.matchmaker_remove(ticket: string, callback?: (message: unknown) => void): unknown

Parameters

  • ticket: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_create(open: boolean, max_size: number, callback?: (message: unknown) => void): unknown

Parameters

  • open: boolean
  • max_size: number
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_join(party_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_leave(party_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_promote(party_id: string, presence: unknown, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • presence: unknown
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_accept(party_id: string, presence: unknown, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • presence: unknown
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_remove(party_id: string, presence: unknown, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • presence: unknown
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_close(party_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_join_request_list(party_id: string, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_matchmaker_add(party_id: string, min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • min_count: number
  • max_count: number
  • query: string
  • string_properties: unknown
  • numeric_properties: unknown
  • count_multiple: number
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_matchmaker_remove(party_id: string, ticket: string, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • ticket: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.party_data_send(party_id: string, op_code: number, data: string, callback?: (message: unknown) => void): unknown

Parameters

  • party_id: string
  • op_code: number
  • data: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.status_follow(user_ids: string, usernames: string, callback?: (message: unknown) => void): unknown

Parameters

  • user_ids: string
  • usernames: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.status_unfollow(user_ids: string, callback?: (message: unknown) => void): unknown

Parameters

  • user_ids: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.status_update(status: string, callback?: (message: unknown) => void): unknown

Parameters

  • status: string
  • callback?: (message: unknown) => void

Returns

  • unknown

Socket.on_channel_presence_event(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_match_presence_event(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_match_data(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_match(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_matchmaker_matched(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_notifications(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_party_presence_event(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_party(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_party_data(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_party_join_request(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_party_leader(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_status_presence_event(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_status(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_stream_data(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_error(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

Socket.on_channel_message(fn: (message: unknown) => void)

Parameters

  • fn: (message: unknown) => void

On this page

Functionscreate(client: unknown): Socketconnect(socket: Socket, callback?: (success: boolean, error?: string) => void): unknownsend(socket: Socket, message: unknown, callback?: (message: unknown) => void): unknownon_disconnect(socket: Socket, fn: () => void)channel_join(socket: Socket, target: string, type: number, persistence: boolean, hidden: boolean, callback?: (message: unknown) => void): unknownchannel_leave(socket: Socket, channel_id: string, callback?: (message: unknown) => void): unknownchannel_message_send(socket: Socket, channel_id: string, content: string, callback?: (message: unknown) => void): unknownchannel_message_remove(socket: Socket, channel_id: string, message_id: string, callback?: (message: unknown) => void): unknownchannel_message_update(socket: Socket, channel_id: string, message_id: string, content: string, callback?: (message: unknown) => void): unknownmatch_data_send(socket: Socket, match_id: string, op_code: number, data: string, presences: unknown, reliable: boolean, callback?: (message: unknown) => void): unknownmatch_create(socket: Socket, name: string | undefined, callback?: (message: unknown) => void): unknownmatch_join(socket: Socket, match_id: string | undefined, token: string | undefined, metadata: unknown, callback?: (message: unknown) => void): unknownmatch_leave(socket: Socket, match_id: string, callback?: (message: unknown) => void): unknownmatchmaker_add(socket: Socket, min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknownmatchmaker_remove(socket: Socket, ticket: string, callback?: (message: unknown) => void): unknownparty_create(socket: Socket, open: boolean, max_size: number, callback?: (message: unknown) => void): unknownparty_join(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknownparty_leave(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknownparty_promote(socket: Socket, party_id: string, presence: unknown, callback?: (message: unknown) => void): unknownparty_accept(socket: Socket, party_id: string, presence: unknown, callback?: (message: unknown) => void): unknownparty_remove(socket: Socket, party_id: string, presence: unknown, callback?: (message: unknown) => void): unknownparty_close(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknownparty_join_request_list(socket: Socket, party_id: string, callback?: (message: unknown) => void): unknownparty_matchmaker_add(socket: Socket, party_id: string, min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknownparty_matchmaker_remove(socket: Socket, party_id: string, ticket: string, callback?: (message: unknown) => void): unknownparty_data_send(socket: Socket, party_id: string, op_code: number, data: string, callback?: (message: unknown) => void): unknownstatus_follow(socket: Socket, user_ids: string, usernames: string, callback?: (message: unknown) => void): unknownstatus_unfollow(socket: Socket, user_ids: string, callback?: (message: unknown) => void): unknownstatus_update(socket: Socket, status: string, callback?: (message: unknown) => void): unknownon_channel_presence_event(socket: Socket, fn: (message: unknown) => void)on_match_presence_event(socket: Socket, fn: (message: unknown) => void)on_match_data(socket: Socket, fn: (message: unknown) => void)on_match(socket: Socket, fn: (message: unknown) => void)on_matchmaker_matched(socket: Socket, fn: (message: unknown) => void)on_notifications(socket: Socket, fn: (message: unknown) => void)on_party_presence_event(socket: Socket, fn: (message: unknown) => void)on_party(socket: Socket, fn: (message: unknown) => void)on_party_data(socket: Socket, fn: (message: unknown) => void)on_party_join_request(socket: Socket, fn: (message: unknown) => void)on_party_leader(socket: Socket, fn: (message: unknown) => void)on_status_presence_event(socket: Socket, fn: (message: unknown) => void)on_status(socket: Socket, fn: (message: unknown) => void)on_stream_data(socket: Socket, fn: (message: unknown) => void)on_error(socket: Socket, fn: (message: unknown) => void)on_channel_message(socket: Socket, fn: (message: unknown) => void)VariablesCHANNELTYPE_UNSPECIFIED: 0CHANNELTYPE_ROOM: 1CHANNELTYPE_DIRECT_MESSAGE: 2CHANNELTYPE_GROUP: 3ERROR_RUNTIME_EXCEPTION: 0ERROR_UNRECOGNIZED_PAYLOAD: 1ERROR_MISSING_PAYLOAD: 2ERROR_BAD_INPUT: 3ERROR_MATCH_NOT_FOUND: 4ERROR_MATCH_JOIN_REJECTED: 5ERROR_RUNTIME_FUNCTION_NOT_FOUND: 6ERROR_RUNTIME_FUNCTION_EXCEPTION: 7TypesSocketSocket.connect(callback?: (success: boolean, error?: string) => void): unknownSocket.send(message: unknown, callback?: (message: unknown) => void): unknownSocket.on_disconnect(fn: () => void)Socket.channel_join(target: string, type: number, persistence: boolean, hidden: boolean, callback?: (message: unknown) => void): unknownSocket.channel_leave(channel_id: string, callback?: (message: unknown) => void): unknownSocket.channel_message_send(channel_id: string, content: string, callback?: (message: unknown) => void): unknownSocket.channel_message_remove(channel_id: string, message_id: string, callback?: (message: unknown) => void): unknownSocket.channel_message_update(channel_id: string, message_id: string, content: string, callback?: (message: unknown) => void): unknownSocket.match_data_send(match_id: string, op_code: number, data: string, presences: unknown, reliable: boolean, callback?: (message: unknown) => void): unknownSocket.match_create(name: string | undefined, callback?: (message: unknown) => void): unknownSocket.match_join(match_id: string | undefined, token: string | undefined, metadata: unknown, callback?: (message: unknown) => void): unknownSocket.match_leave(match_id: string, callback?: (message: unknown) => void): unknownSocket.matchmaker_add(min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknownSocket.matchmaker_remove(ticket: string, callback?: (message: unknown) => void): unknownSocket.party_create(open: boolean, max_size: number, callback?: (message: unknown) => void): unknownSocket.party_join(party_id: string, callback?: (message: unknown) => void): unknownSocket.party_leave(party_id: string, callback?: (message: unknown) => void): unknownSocket.party_promote(party_id: string, presence: unknown, callback?: (message: unknown) => void): unknownSocket.party_accept(party_id: string, presence: unknown, callback?: (message: unknown) => void): unknownSocket.party_remove(party_id: string, presence: unknown, callback?: (message: unknown) => void): unknownSocket.party_close(party_id: string, callback?: (message: unknown) => void): unknownSocket.party_join_request_list(party_id: string, callback?: (message: unknown) => void): unknownSocket.party_matchmaker_add(party_id: string, min_count: number, max_count: number, query: string, string_properties: unknown, numeric_properties: unknown, count_multiple: number, callback?: (message: unknown) => void): unknownSocket.party_matchmaker_remove(party_id: string, ticket: string, callback?: (message: unknown) => void): unknownSocket.party_data_send(party_id: string, op_code: number, data: string, callback?: (message: unknown) => void): unknownSocket.status_follow(user_ids: string, usernames: string, callback?: (message: unknown) => void): unknownSocket.status_unfollow(user_ids: string, callback?: (message: unknown) => void): unknownSocket.status_update(status: string, callback?: (message: unknown) => void): unknownSocket.on_channel_presence_event(fn: (message: unknown) => void)Socket.on_match_presence_event(fn: (message: unknown) => void)Socket.on_match_data(fn: (message: unknown) => void)Socket.on_match(fn: (message: unknown) => void)Socket.on_matchmaker_matched(fn: (message: unknown) => void)Socket.on_notifications(fn: (message: unknown) => void)Socket.on_party_presence_event(fn: (message: unknown) => void)Socket.on_party(fn: (message: unknown) => void)Socket.on_party_data(fn: (message: unknown) => void)Socket.on_party_join_request(fn: (message: unknown) => void)Socket.on_party_leader(fn: (message: unknown) => void)Socket.on_status_presence_event(fn: (message: unknown) => void)Socket.on_status(fn: (message: unknown) => void)Socket.on_stream_data(fn: (message: unknown) => void)Socket.on_error(fn: (message: unknown) => void)Socket.on_channel_message(fn: (message: unknown) => void)