Skip to Content
defold-typescript libraries
heroiclabsnakama-defold

heroiclabs/nakama-defold/nakama.engine.defold

Defold engine adapter for the Nakama client: UUID, HTTP, and realtime socket helpers.

  • 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 engine_defold from "nakama.engine.defold"

Functions

uuid(): stringU

Returns a UUID from the device's mac address.

Returns

  • string — The UUID string.

http(config: unknown, url_path: string, query_params: string, method: string, post_data: string, retry_policy: unknown, cancellation_token: unknown, callback: (response: unknown) => void)U

Make a HTTP request.

Parameters

  • config: unknown — The http config table, see Defold docs.
  • url_path: string — The request URL.
  • query_params: string — Query params string.
  • method: string — The HTTP method string.
  • post_data: string — String of post data.
  • retry_policy: unknown
  • cancellation_token: unknown
  • callback: (response: unknown) => void — The callback function.

socket_create(config: unknown, on_message: (socket: symbol, message: unknown) => void)U

Create a new socket with message handler.

Parameters

  • config: unknown — The socket config table, see Defold docs.
  • on_message: (socket: symbol, message: unknown) => void — Your function to process socket messages.

socket_connect(socket: symbol, callback: (success: boolean, error: string) => void)U

Connect a created socket using web sockets.

Parameters

  • socket: symbol — The socket table, see socket_create.
  • callback: (success: boolean, error: string) => void — The callback function.

socket_send(socket: symbol, message: string)U

Send a socket message.

Parameters

  • socket: symbol — The socket table, see socket_create.
  • message: string — The message string to send.

On this page