Options
All
  • Public
  • Public/Protected
  • All
Menu

A client for Nakama server.

Hierarchy

  • Client

Index

Constructors

constructor

  • new Client(serverkey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, autoRefreshSession?: boolean): Client
  • 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

Private Readonly apiClient

apiClient: NakamaApi

Readonly autoRefreshSession

autoRefreshSession: boolean = true

expiredTimespanMs

expiredTimespanMs: number = DEFAULT_EXPIRED_TIMESPAN_MS

Readonly host

host: string = DEFAULT_HOST

Readonly port

port: string = DEFAULT_PORT

Readonly serverkey

serverkey: string = DEFAULT_SERVER_KEY

Readonly timeout

timeout: number = DEFAULT_TIMEOUT_MS

Readonly useSSL

useSSL: boolean = false

Methods

addFriends

  • addFriends(session: Session, ids?: string[], usernames?: string[]): Promise<boolean>
  • Add friends by ID or username to a user's account.

    Parameters

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

    Returns Promise<boolean>

addGroupUsers

  • addGroupUsers(session: Session, groupId: string, ids?: string[]): Promise<boolean>
  • Add users to a group, or accept their join requests.

    Parameters

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

    Returns Promise<boolean>

authenticateApple

  • authenticateApple(token: string, create?: false | true, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>
  • Authenticate a user with an Apple ID against the server.

    Parameters

    • token: string
    • Optional create: false | true
    • Optional username: string
    • vars: Map<string, string> = ...
    • options: any = {}

    Returns Promise<Session>

authenticateCustom

  • authenticateCustom(id: string, create?: false | true, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>
  • Authenticate a user with a custom id against the server.

    Parameters

    • id: string
    • Optional create: false | true
    • Optional username: string
    • vars: Map<string, string> = ...
    • options: any = {}

    Returns Promise<Session>

authenticateDevice

  • authenticateDevice(id: string, create?: false | true, username?: string, vars?: Map<string, string>): Promise<Session>
  • Authenticate a user with a device id against the server.

    Parameters

    • id: string
    • Optional create: false | true
    • Optional username: string
    • Optional vars: Map<string, string>

    Returns Promise<Session>

authenticateEmail

  • authenticateEmail(email: string, password: string, create?: false | true, username?: string, vars?: Map<string, string>): Promise<Session>
  • Authenticate a user with an email+password against the server.

    Parameters

    • email: string
    • password: string
    • Optional create: false | true
    • Optional username: string
    • Optional vars: Map<string, string>

    Returns Promise<Session>

authenticateFacebook

  • authenticateFacebook(token: string, create?: false | true, username?: string, sync?: false | true, vars?: Map<string, string>, options?: any): Promise<Session>
  • Authenticate a user with a Facebook OAuth token against the server.

    Parameters

    • token: string
    • Optional create: false | true
    • Optional username: string
    • Optional sync: false | true
    • Optional vars: Map<string, string>
    • options: any = {}

    Returns Promise<Session>

authenticateFacebookInstantGame

  • authenticateFacebookInstantGame(signedPlayerInfo: string, create?: false | true, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>
  • Authenticate a user with a Facebook Instant Game token against the server.

    Parameters

    • signedPlayerInfo: string
    • Optional create: false | true
    • Optional username: string
    • Optional vars: Map<string, string>
    • options: any = {}

    Returns Promise<Session>

authenticateGameCenter

  • authenticateGameCenter(token: string, create?: false | true, username?: string, vars?: Map<string, string>): Promise<Session>
  • Authenticate a user with GameCenter against the server.

    Parameters

    • token: string
    • Optional create: false | true
    • Optional username: string
    • Optional vars: Map<string, string>

    Returns Promise<Session>

authenticateGoogle

  • authenticateGoogle(token: string, create?: false | true, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>
  • Authenticate a user with Google against the server.

    Parameters

    • token: string
    • Optional create: false | true
    • Optional username: string
    • Optional vars: Map<string, string>
    • options: any = {}

    Returns Promise<Session>

authenticateSteam

  • authenticateSteam(token: string, create?: false | true, username?: string, sync?: false | true, vars?: Map<string, string>): Promise<Session>
  • Authenticate a user with Steam against the server.

    Parameters

    • token: string
    • Optional create: false | true
    • Optional username: string
    • Optional sync: false | true
    • Optional vars: Map<string, string>

    Returns Promise<Session>

banGroupUsers

  • banGroupUsers(session: Session, groupId: string, ids?: string[]): Promise<boolean>
  • Ban users from a group.

    Parameters

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

    Returns Promise<boolean>

blockFriends

  • blockFriends(session: Session, ids?: string[], usernames?: string[]): Promise<boolean>
  • Block one or more users by ID or username.

    Parameters

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

    Returns Promise<boolean>

createGroup

  • createGroup(session: Session, request: ApiCreateGroupRequest): Promise<Group>
  • Create a new group with the current user as the creator and superadmin.

    Parameters

    • session: Session
    • request: ApiCreateGroupRequest

    Returns Promise<Group>

createSocket

  • A socket created with the client's configuration.

    Parameters

    Returns Socket

deleteFriends

  • deleteFriends(session: Session, ids?: string[], usernames?: string[]): Promise<boolean>
  • Delete one or more users by ID or username.

    Parameters

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

    Returns Promise<boolean>

deleteGroup

  • deleteGroup(session: Session, groupId: string): Promise<boolean>
  • Delete a group the user is part of and has permissions to delete.

    Parameters

    Returns Promise<boolean>

deleteNotifications

  • deleteNotifications(session: Session, ids?: string[]): Promise<boolean>
  • Delete one or more notifications

    Parameters

    • session: Session
    • Optional ids: string[]

    Returns Promise<boolean>

deleteStorageObjects

  • deleteStorageObjects(session: Session, request: ApiDeleteStorageObjectsRequest): Promise<boolean>
  • Delete one or more storage objects

    Parameters

    • session: Session
    • request: ApiDeleteStorageObjectsRequest

    Returns Promise<boolean>

demoteGroupUsers

  • demoteGroupUsers(session: Session, groupId: string, ids: string[]): Promise<boolean>
  • Demote a set of users in a group to the next role down.

    Parameters

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

    Returns Promise<boolean>

emitEvent

  • emitEvent(session: Session, request: ApiEvent): Promise<boolean>
  • Submit an event for processing in the server's registered runtime custom events handler.

    Parameters

    Returns Promise<boolean>

getAccount

  • getAccount(session: Session): Promise<ApiAccount>
  • Fetch the current user's account.

    Parameters

    Returns Promise<ApiAccount>

getUsers

  • getUsers(session: Session, ids?: string[], usernames?: string[], facebookIds?: string[]): Promise<Users>
  • 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>

importFacebookFriends

  • importFacebookFriends(session: Session, request: ApiAccountFacebook): Promise<boolean>
  • Import Facebook friends and add them to a user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebook

    Returns Promise<boolean>

importSteamFriends

  • importSteamFriends(session: Session, request: ApiAccountSteam, reset: boolean): Promise<boolean>
  • Import Steam friends and add them to a user's account.

    Parameters

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

    Returns Promise<boolean>

joinGroup

  • joinGroup(session: Session, groupId: string): Promise<boolean>
  • Join a group that's open, or send a request to join a group that is closed.

    Parameters

    Returns Promise<boolean>

joinTournament

  • joinTournament(session: Session, tournamentId: string): Promise<boolean>

kickGroupUsers

  • kickGroupUsers(session: Session, groupId: string, ids?: string[]): Promise<boolean>
  • Kick users from a group, or decline their join requests.

    Parameters

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

    Returns Promise<boolean>

leaveGroup

  • leaveGroup(session: Session, groupId: string): Promise<boolean>
  • Leave a group the user is part of.

    Parameters

    Returns Promise<boolean>

linkApple

  • linkApple(session: Session, request: ApiAccountApple): Promise<boolean>
  • Add an Apple ID to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountApple

    Returns Promise<boolean>

linkCustom

  • linkCustom(session: Session, request: ApiAccountCustom): Promise<boolean>
  • Add a custom ID to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountCustom

    Returns Promise<boolean>

linkDevice

  • linkDevice(session: Session, request: ApiAccountDevice): Promise<boolean>
  • Add a device ID to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountDevice

    Returns Promise<boolean>

linkEmail

  • linkEmail(session: Session, request: ApiAccountEmail): Promise<boolean>
  • Add an email+password to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountEmail

    Returns Promise<boolean>

linkFacebook

  • linkFacebook(session: Session, request: ApiAccountFacebook): Promise<boolean>
  • Add Facebook to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebook

    Returns Promise<boolean>

linkFacebookInstantGame

  • linkFacebookInstantGame(session: Session, request: ApiAccountFacebookInstantGame): Promise<boolean>
  • Add Facebook Instant to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebookInstantGame

    Returns Promise<boolean>

linkGameCenter

  • linkGameCenter(session: Session, request: ApiAccountGameCenter): Promise<boolean>
  • Add GameCenter to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGameCenter

    Returns Promise<boolean>

linkGoogle

  • linkGoogle(session: Session, request: ApiAccountGoogle): Promise<boolean>
  • Add Google to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGoogle

    Returns Promise<boolean>

linkSteam

  • linkSteam(session: Session, request: ApiLinkSteamRequest): Promise<boolean>
  • Add Steam to the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiLinkSteamRequest

    Returns Promise<boolean>

listChannelMessages

  • listChannelMessages(session: Session, channelId: string, limit?: number, forward?: false | true, cursor?: string): Promise<ChannelMessageList>
  • List a channel's message history.

    Parameters

    • session: Session
    • channelId: string
    • Optional limit: number
    • Optional forward: false | true
    • Optional cursor: string

    Returns Promise<ChannelMessageList>

listFriends

  • listFriends(session: Session, state?: number, limit?: number, cursor?: string): Promise<Friends>
  • List all friends for the current user.

    Parameters

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

    Returns Promise<Friends>

listGroupUsers

  • listGroupUsers(session: Session, groupId: string, state?: number, limit?: number, cursor?: string): Promise<GroupUserList>
  • List a group's users.

    Parameters

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

    Returns Promise<GroupUserList>

listGroups

  • listGroups(session: Session, name?: string, cursor?: string, limit?: number): Promise<GroupList>
  • List groups based on given filters.

    Parameters

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

    Returns Promise<GroupList>

listLeaderboardRecords

  • listLeaderboardRecords(session: Session, leaderboardId: string, ownerIds?: string[], limit?: number, cursor?: string, expiry?: string): Promise<LeaderboardRecordList>
  • List leaderboard records

    Parameters

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

    Returns Promise<LeaderboardRecordList>

listLeaderboardRecordsAroundOwner

  • listLeaderboardRecordsAroundOwner(session: Session, leaderboardId: string, ownerId: string, limit?: number, expiry?: string): Promise<LeaderboardRecordList>

listMatches

  • listMatches(session: Session, limit?: number, authoritative?: false | true, label?: string, minSize?: number, maxSize?: number, query?: string): Promise<ApiMatchList>
  • Fetch list of running matches.

    Parameters

    • session: Session
    • Optional limit: number
    • Optional authoritative: false | true
    • Optional label: string
    • Optional minSize: number
    • Optional maxSize: number
    • Optional query: string

    Returns Promise<ApiMatchList>

listNotifications

listStorageObjects

  • listStorageObjects(session: Session, collection: string, userId?: string, limit?: number, cursor?: string): Promise<StorageObjectList>
  • List storage objects.

    Parameters

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

    Returns Promise<StorageObjectList>

listTournamentRecords

  • listTournamentRecords(session: Session, tournamentId: string, ownerIds?: string[], limit?: number, cursor?: string, expiry?: string): Promise<TournamentRecordList>
  • 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>

listTournamentRecordsAroundOwner

  • listTournamentRecordsAroundOwner(session: Session, tournamentId: string, ownerId: string, limit?: number, expiry?: string): 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

    Returns Promise<TournamentRecordList>

listTournaments

  • listTournaments(session: Session, categoryStart?: number, categoryEnd?: number, startTime?: number, endTime?: number, limit?: number, cursor?: string): Promise<TournamentList>
  • 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>

listUserGroups

  • listUserGroups(session: Session, userId: string, state?: number, limit?: number, cursor?: string): Promise<UserGroupList>
  • List a user's groups.

    Parameters

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

    Returns Promise<UserGroupList>

promoteGroupUsers

  • promoteGroupUsers(session: Session, groupId: string, ids?: string[]): Promise<boolean>
  • Promote users in a group to the next role up.

    Parameters

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

    Returns Promise<boolean>

readStorageObjects

rpc

rpcHttpKey

  • rpcHttpKey(httpKey: string, id: string, input?: object): Promise<RpcResponse>
  • Execute an RPC function on the server.

    Parameters

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

    Returns Promise<RpcResponse>

sessionLogout

  • sessionLogout(session: Session, token: string, refreshToken: string): Promise<boolean>
  • 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>

sessionRefresh

  • sessionRefresh(session: Session, vars?: Map<string, string>): Promise<Session>
  • Refresh a user's session using a refresh token retrieved from a previous authentication request.

    Parameters

    • session: Session
    • vars: Map<string, string> = ...

    Returns Promise<Session>

unlinkApple

  • unlinkApple(session: Session, request: ApiAccountApple): Promise<boolean>
  • Remove the Apple ID from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountApple

    Returns Promise<boolean>

unlinkCustom

  • unlinkCustom(session: Session, request: ApiAccountCustom): Promise<boolean>
  • Remove custom ID from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountCustom

    Returns Promise<boolean>

unlinkDevice

  • unlinkDevice(session: Session, request: ApiAccountDevice): Promise<boolean>
  • Remove a device ID from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountDevice

    Returns Promise<boolean>

unlinkEmail

  • unlinkEmail(session: Session, request: ApiAccountEmail): Promise<boolean>
  • Remove an email+password from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountEmail

    Returns Promise<boolean>

unlinkFacebook

  • unlinkFacebook(session: Session, request: ApiAccountFacebook): Promise<boolean>
  • Remove Facebook from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebook

    Returns Promise<boolean>

unlinkFacebookInstantGame

  • unlinkFacebookInstantGame(session: Session, request: ApiAccountFacebookInstantGame): Promise<boolean>
  • Remove Facebook Instant social profiles from the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountFacebookInstantGame

    Returns Promise<boolean>

unlinkGameCenter

  • unlinkGameCenter(session: Session, request: ApiAccountGameCenter): Promise<boolean>
  • Remove GameCenter from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGameCenter

    Returns Promise<boolean>

unlinkGoogle

  • unlinkGoogle(session: Session, request: ApiAccountGoogle): Promise<boolean>
  • Remove Google from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountGoogle

    Returns Promise<boolean>

unlinkSteam

  • unlinkSteam(session: Session, request: ApiAccountSteam): Promise<boolean>
  • Remove Steam from the social profiles on the current user's account.

    Parameters

    • session: Session
    • request: ApiAccountSteam

    Returns Promise<boolean>

updateAccount

  • updateAccount(session: Session, request: ApiUpdateAccountRequest): Promise<boolean>
  • Update fields in the current user's account.

    Parameters

    • session: Session
    • request: ApiUpdateAccountRequest

    Returns Promise<boolean>

updateGroup

  • updateGroup(session: Session, groupId: string, request: ApiUpdateGroupRequest): 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>

validatePurchaseApple

  • validatePurchaseApple(session: Session, receipt?: string): Promise<ApiValidatePurchaseResponse>
  • Validate an Apple IAP receipt.

    Parameters

    • session: Session
    • Optional receipt: string

    Returns Promise<ApiValidatePurchaseResponse>

validatePurchaseGoogle

  • validatePurchaseGoogle(session: Session, purchase?: string): Promise<ApiValidatePurchaseResponse>
  • Validate a Google IAP receipt.

    Parameters

    • session: Session
    • Optional purchase: string

    Returns Promise<ApiValidatePurchaseResponse>

validatePurchaseHuawei

  • validatePurchaseHuawei(session: Session, purchase?: string, signature?: string): Promise<ApiValidatePurchaseResponse>
  • Validate a Huawei IAP receipt.

    Parameters

    • session: Session
    • Optional purchase: string
    • Optional signature: string

    Returns Promise<ApiValidatePurchaseResponse>

writeLeaderboardRecord

writeStorageObjects

writeTournamentRecord

Generated using TypeDoc