A client for Nakama server.

Hierarchy

  • Client

Constructors

Properties

Methods

Constructors

  • Parameters

    • serverkey: string = DEFAULT_SERVER_KEY
    • host: string = DEFAULT_HOST
    • port: string = DEFAULT_PORT
    • useSSL: boolean = false
    • timeout: number = DEFAULT_TIMEOUT_MS
    • autoRefreshSession: boolean = true

    Returns Client

Properties

apiClient: NakamaApi

The low level API client for Nakama server.

autoRefreshSession: boolean = true
expiredTimespanMs: number = DEFAULT_EXPIRED_TIMESPAN_MS

The expired timespan used to check session lifetime.

host: string = DEFAULT_HOST
port: string = DEFAULT_PORT
serverkey: string = DEFAULT_SERVER_KEY
timeout: number = DEFAULT_TIMEOUT_MS
useSSL: boolean = false

Methods

  • Add friends by ID or username to a user's account.

    Parameters

    • session: Session
    • Optional ids: string[]
    • Optional usernames: string[]

    Returns Promise<boolean>

  • Add users to a group, or accept their join requests.

    Parameters

    • session: Session
    • groupId: string
    • Optional ids: string[]

    Returns Promise<boolean>

  • Authenticate a user with an Apple ID against the server.

    Parameters

    • token: string
    • Optional create: boolean
    • Optional username: string
    • vars: Record<string, string> = {}
    • options: any = {}

    Returns Promise<Session>

  • Authenticate a user with a custom id against the server.

    Parameters

    • id: string
    • Optional create: boolean
    • Optional username: string
    • vars: Record<string, string> = {}
    • options: any = {}

    Returns Promise<Session>

  • Authenticate a user with a device id against the server.

    Parameters

    • id: string
    • Optional create: boolean
    • Optional username: string
    • Optional vars: Record<string, string>

    Returns Promise<Session>

  • Authenticate a user with an email+password against the server.

    Parameters

    • email: string
    • password: string
    • Optional create: boolean
    • Optional username: string
    • Optional vars: Record<string, string>

    Returns Promise<Session>

  • Authenticate a user with a Facebook OAuth token against the server.

    Parameters

    • token: string
    • Optional create: boolean
    • Optional username: string
    • Optional sync: boolean
    • Optional vars: Record<string, string>
    • options: any = {}

    Returns Promise<Session>

  • Authenticate a user with a Facebook Instant Game token against the server.

    Parameters

    • signedPlayerInfo: string
    • Optional create: boolean
    • Optional username: string
    • Optional vars: Record<string, string>
    • options: any = {}

    Returns Promise<Session>

  • Authenticate a user with GameCenter against the server.

    Parameters

    • bundleId: string
    • playerId: string
    • publicKeyUrl: string
    • salt: string
    • signature: string
    • timestamp: string
    • Optional username: string
    • Optional create: boolean
    • Optional vars: Record<string, string>
    • options: any = {}

    Returns Promise<Session>

  • Authenticate a user with Google against the server.

    Parameters

    • token: string
    • Optional create: boolean
    • Optional username: string
    • Optional vars: Record<string, string>
    • options: any = {}

    Returns Promise<Session>

  • Authenticate a user with Steam against the server.

    Parameters

    • token: string
    • Optional create: boolean
    • Optional username: string
    • Optional sync: boolean
    • Optional vars: Record<string, string>

    Returns Promise<Session>

  • Ban users from a group.

    Parameters

    • session: Session
    • groupId: string
    • Optional ids: string[]

    Returns Promise<boolean>

  • Block one or more users by ID or username.

    Parameters

    • session: Session
    • Optional ids: string[]
    • Optional usernames: string[]

    Returns Promise<boolean>

  • Create a new group with the current user as the creator and superadmin.

    Parameters

    • session: Session
    • request: ApiCreateGroupRequest

    Returns Promise<Group>

  • A socket created with the client's configuration.

    Parameters

    • useSSL: boolean = false
    • verbose: boolean = false
    • adapter: WebSocketAdapter = ...
    • sendTimeoutMs: number = DefaultSocket.DefaultSendTimeoutMs

    Returns Socket

  • Delete one or more users by ID or username.

    Parameters

    • session: Session
    • Optional ids: string[]
    • Optional usernames: string[]

    Returns Promise<boolean>

  • Delete a group the user is part of and has permissions to delete.

    Parameters

    Returns Promise<boolean>

  • Delete one or more notifications

    Parameters

    • session: Session
    • Optional ids: string[]

    Returns Promise<boolean>

  • Delete one or more storage objects

    Parameters

    • session: Session
    • request: ApiDeleteStorageObjectsRequest

    Returns Promise<boolean>

  • Delete a tournament record.

    Parameters

    • session: Session
    • tournamentId: string

    Returns Promise<any>

  • Demote a set of users in a group to the next role down.

    Parameters

    • session: Session
    • groupId: string
    • ids: string[]

    Returns Promise<boolean>

  • Submit an event for processing in the server's registered runtime custom events handler.

    Parameters

    • session: Session
    • request: ApiEvent

    Returns Promise<boolean>

  • Get subscription by product id.

    Parameters

    • session: Session
    • productId: string

    Returns Promise<ApiValidatedSubscription>

  • Fetch zero or more users by ID and/or username.

    Parameters

    • session: Session
    • Optional ids: string[]
    • Optional usernames: string[]
    • Optional facebookIds: string[]

    Returns Promise<Users>

  • Import Facebook friends and add them to a user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebook

    Returns Promise<boolean>

  • Import Steam friends and add them to a user's account.

    Parameters

    • session: Session
    • request: ApiAccountSteam
    • reset: boolean

    Returns Promise<boolean>

  • Join a group that's open, or send a request to join a group that is closed.

    Parameters

    Returns Promise<boolean>

  • Kick users from a group, or decline their join requests.

    Parameters

    • session: Session
    • groupId: string
    • Optional ids: string[]

    Returns Promise<boolean>

  • Leave a group the user is part of.

    Parameters

    Returns Promise<boolean>

  • Add an Apple ID to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountApple

    Returns Promise<boolean>

  • Add a custom ID to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountCustom

    Returns Promise<boolean>

  • Add a device ID to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountDevice

    Returns Promise<boolean>

  • Add an email+password to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountEmail

    Returns Promise<boolean>

  • Add Facebook to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebook

    Returns Promise<boolean>

  • Add Facebook Instant to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebookInstantGame

    Returns Promise<boolean>

  • Add GameCenter to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGameCenter

    Returns Promise<boolean>

  • Add Google to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGoogle

    Returns Promise<boolean>

  • Add Steam to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiLinkSteamRequest

    Returns Promise<boolean>

  • List all friends for the current user.

    Parameters

    • session: Session
    • Optional state: number
    • Optional limit: number
    • Optional cursor: string

    Returns Promise<Friends>

  • List a group's users.

    Parameters

    • session: Session
    • groupId: string
    • Optional state: number
    • Optional limit: number
    • Optional cursor: string

    Returns Promise<GroupUserList>

  • List groups based on given filters.

    Parameters

    • session: Session
    • Optional name: string
    • Optional cursor: string
    • Optional limit: number

    Returns Promise<GroupList>

  • List leaderboard records

    Parameters

    • session: Session
    • leaderboardId: string
    • Optional ownerIds: string[]
    • Optional limit: number
    • Optional cursor: string
    • Optional expiry: string

    Returns Promise<LeaderboardRecordList>

  • Fetch list of running matches.

    Parameters

    • session: Session
    • Optional limit: number
    • Optional authoritative: boolean
    • Optional label: string
    • Optional minSize: number
    • Optional maxSize: number
    • Optional query: string

    Returns Promise<ApiMatchList>

  • List tournament records from a given tournament.

    Parameters

    • session: Session
    • tournamentId: string
    • Optional ownerIds: string[]
    • Optional limit: number
    • Optional cursor: string
    • Optional expiry: string

    Returns Promise<TournamentRecordList>

  • List tournament records from a given tournament around the owner.

    Parameters

    • session: Session
    • tournamentId: string
    • ownerId: string
    • Optional limit: number
    • Optional expiry: string
    • Optional cursor: string

    Returns Promise<TournamentRecordList>

  • List current or upcoming tournaments.

    Parameters

    • session: Session
    • Optional categoryStart: number
    • Optional categoryEnd: number
    • Optional startTime: number
    • Optional endTime: number
    • Optional limit: number
    • Optional cursor: string

    Returns Promise<TournamentList>

  • List a user's groups.

    Parameters

    • session: Session
    • userId: string
    • Optional state: number
    • Optional limit: number
    • Optional cursor: string

    Returns Promise<UserGroupList>

  • Promote users in a group to the next role up.

    Parameters

    • session: Session
    • groupId: string
    • Optional ids: string[]

    Returns Promise<boolean>

  • Execute an RPC function on the server.

    Parameters

    • httpKey: string
    • id: string
    • Optional input: object

    Returns Promise<RpcResponse>

  • Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user.

    Parameters

    • session: Session
    • token: string
    • refreshToken: string

    Returns Promise<boolean>

  • Refresh a user's session using a refresh token retrieved from a previous authentication request.

    Parameters

    • session: Session
    • vars: Record<string, string> = {}

    Returns Promise<Session>

  • Remove the Apple ID from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountApple

    Returns Promise<boolean>

  • Remove custom ID from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountCustom

    Returns Promise<boolean>

  • Remove a device ID from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountDevice

    Returns Promise<boolean>

  • Remove an email+password from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountEmail

    Returns Promise<boolean>

  • Remove Facebook from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebook

    Returns Promise<boolean>

  • Remove Facebook Instant social profiles from the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebookInstantGame

    Returns Promise<boolean>

  • Remove GameCenter from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGameCenter

    Returns Promise<boolean>

  • Remove Google from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGoogle

    Returns Promise<boolean>

  • Remove Steam from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountSteam

    Returns Promise<boolean>

  • Update fields in the current user's account.

    Parameters

    • session: Session
    • request: ApiUpdateAccountRequest

    Returns Promise<boolean>

  • Update a group the user is part of and has permissions to update.

    Parameters

    • session: Session
    • groupId: string
    • request: ApiUpdateGroupRequest

    Returns Promise<boolean>

  • Validate an Apple IAP receipt.

    Parameters

    • session: Session
    • Optional receipt: string
    • persist: boolean = true

    Returns Promise<ApiValidatePurchaseResponse>

  • Validate a FB Instant IAP receipt.

    Parameters

    • session: Session
    • Optional signedRequest: string
    • persist: boolean = true

    Returns Promise<ApiValidatePurchaseResponse>

  • Validate a Google IAP receipt.

    Parameters

    • session: Session
    • Optional purchase: string
    • persist: boolean = true

    Returns Promise<ApiValidatePurchaseResponse>

  • Validate a Huawei IAP receipt.

    Parameters

    • session: Session
    • Optional purchase: string
    • Optional signature: string
    • persist: boolean = true

    Returns Promise<ApiValidatePurchaseResponse>

  • Validate Apple Subscription Receipt

    Parameters

    • session: Session
    • receipt: string
    • persist: boolean = true

    Returns Promise<ApiValidateSubscriptionResponse>

  • Validate Google Subscription Receipt

    Parameters

    • session: Session
    • receipt: string
    • persist: boolean = true

    Returns Promise<ApiValidateSubscriptionResponse>

Generated using TypeDoc