Back to Top

gbase-html5-sdk master

JavaScript client library for Goblin Base/Cloud server

Gbase()

To work with API you need to instantiate GbaseApi object.

Returns

Void

constructor(projectName, projectEnvironment, hmacSecret, platform, semVersion, _overrideUrlAddress)

La constructor. Every instance of this class holds it's own instance of NetworkManager with corresponding sequence, unicorn and sign up stuff.

Parameters

Name Type Description
projectName
  • your project name like {abbreviated company name}-{abbreviated app name}
projectEnvironment
  • it's common practice to use any of these three: dev, qa or production
hmacSecret
  • a key for connection. Used for signing all messages. All platforms has different secrets. Also they can change between versions. You can get it by contacting us
platform
  • can see all available platforms using GbaseApi.PLATFORM;
semVersion
  • semantic version of current client build
_overrideUrlAddress
  • you can use it to specially override address. But usually you won't have to

Returns

Void

userInputBeenDone()

A very important method. You should call it once any of user input happen. Gbase sessions are tend to rot hence API client configured to ping it once a while but it will stop after some time if no user input been done. So do call.

Returns

Void

dropCache()

This asset uses a cache engine to store Gbase credentials automatically. Use this method to force clear the cache.

Returns

Void

cloudFunction(functionName, argumentsToTransfer, callback)

Call a defined cloud function. It's a special guys that allows you to run domain logic on backend side - an authoritarian logic.

Parameters

Name Type Description
functionName
  • string
argumentsToTransfer
  • any object
callback
  • standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API holds all account related actions: authentication, linking and checking

Returns

Void

signupGbaseAnon(callback)

Anonymous signing up. You will get gClientId and gClientSecret in response - save it and use for further signing ins.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

signupGbaseCustomCredentials(gbaseLogin, gbasePassword, callback)

Signing up similar to anonymous but you provide login and password by your self.

Parameters

Name Type Description
gbaseLogin

{String} - an alternative to gClientId. It should match G_CLIENT_ID_REGEXP

gbasePassword

{String} - an alternative to gClientSecret. It should match G_CLIENT_SECRET_REGEXP

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

signinGbase(gbaseIdOrLogin, gbaseSecretOrPassword, callback)

Signing in using your login and password or previously received gClientId and gClientSecret. After that you only get session unicorn and account info. To work with API you need to create or get your profile.

Parameters

Name Type Description
gbaseIdOrLogin

{String} - self titled

gbaseSecretOrPassword

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

authWebVk(vkId, vkSecret, callback)

Use this authentication method if you use WEBVK platform and your game published inside of VK.com iframe. You will get needed arguments from it to successfully prove your identity.

Parameters

Name Type Description
vkId

{String} - an ID provided by VK.com website

vkSecret

{String} - a secret generated by VK.com website(find out more in VK.com documentation)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

authVkSdk(tokenFromVk, callback)

You can still use VK.com services for authentication if you making standalone or mobile app. SDK is provided and you can use it to redeem a token. Provide this token here and Gbase backend will check it on its side.

Parameters

Name Type Description
tokenFromVk

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

authWebOk(okId, okSecret, okSessionKey, callback)

Use this authentication method if you use WEBOK platform and your game published inside of OK.ru iframe. You will get needed arguments from it to successfully prove your identity.

Parameters

Name Type Description
okId

{String} - an ID provided by OK.ru website

okSecret

{String} - a secret generated by OK.ru website(find out more in OK.ru documentation)

okSessionKey

{String} - a key generated by OK.ru website(find out more in OK.ru documentation)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

authOkSdk(tokenFromOk, callback)

You can still use OK.ru services for authentication if you making standalone or mobile app. SDK is provided and you can use it to redeem a token. Provide this token here and Gbase backend will check it on its side.

Parameters

Name Type Description
tokenFromOk

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

authFb(tokenFromFb, callback)

An authentication using Facebook token. It can be taken from Facebook SDK or from Facebook iframe. And no restrictions on platform.

Parameters

Name Type Description
tokenFromFb

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

reAuth(callback)

Helper method to sign in again or repeat authentication using previously used. A helpful one if you'll once experience session rot.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

signout()

Just sign out and drop sequence, unicorn and other appropriate data.

Returns

Void

linkVkProfile(tokenFromVk, noNewProfile, callback)

Link your previously made account with VK.com profile. After that you will be able to sign in with gClientId, gClientSecret pair and using token from VK.com SDK. It will create new profile or link with previously created if you even once authenticated using VK.com credentials. After this procedure you need to relogin. You can provide an argument "noNewProfile" to link your current profile with social profile. It will make your account bi-login - you be able to login with both gClientId/gClientSecret and social token. This action is irreversible.

Parameters

Name Type Description
tokenFromVk

{String} - self titled

noNewProfile

{boolean} - to create or not new profile

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

linkOkProfile(tokenFromOk, noNewProfile, callback)

Link your previously made account with OK.ru profile. After that you will be able to sign in with gClientId, gClientSecret pair and using token from OK.ru SDK. It will create new profile or link with previously created if you even once authenticated using OK.ru credentials. After this procedure you need to relogin. You can provide an argument "noNewProfile" to link your current profile with social profile. It will make your account bi-login - you be able to login with both gClientId/gClientSecret and social token. This action is irreversible.

Parameters

Name Type Description
tokenFromOk

{String} - self titled

noNewProfile

{boolean} - to create or not new profile

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

linkFbProfile(tokenFromFb, noNewProfile, callback)

Link your previously made account with Facebook profile. After that you will be able to sign in with gClientId, gClientSecret pair and using token from Facebook SDK. It will create new profile or link with previously created if you even once authenticated using Facebook token. After this procedure you need to relogin. You can provide an argument "noNewProfile" to link your current profile with social profile. It will make your account bi-login - you be able to login with both gClientId/gClientSecret and social token. This action is irreversible.

Parameters

Name Type Description
tokenFromFb

{String} - self titled

noNewProfile

{boolean} - to create or not new profile

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

unlinkSocialProfile(callback)

Unlink your previously made account from any social profile. And links account with original Gbase profile. A new profile made while linkage still can be accessed if you'll link once more or if authenticate with social credentials. After this procedure you need to relogin.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

hasVkProfile(tokenFromVk, callback)

Checks if there any profile exists linked with particular VK.com profile. ID of VK.com profile determined by tokenFromVk. It's useful to call before linking without creation new profile. Otherwise you will just get an error.

Parameters

Name Type Description
tokenFromVk

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

hasOkProfile(tokenFromOk, callback)

Checks if there any profile exists linked with particular OK.com profile. ID of OK.com profile determined by tokenFromOk. It's useful to call before linking without creation new profile. Otherwise you will just get an error.

Parameters

Name Type Description
tokenFromOk

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

hasFbProfile(tokenFromFb, callback)

Checks if there any profile exists linked with particular Facebook profile. ID of Facebook profile determined by tokenFromFb. It's useful to call before linking without creation new profile. Otherwise you will just get an error.

Parameters

Name Type Description
tokenFromFb

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API host all profiles related: getting, setting and updating

Returns

Void

create(callback)

After first signing up, in or authentication you need a profile. You can't do anything without profile so create. It has several root nodes: Object profileData, Object publicProfileData, int rating, int mmr, int wlRate, int ver and humanId. You can modify them later except humanId.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getp(callback)

Just get your profile after login. It's a necessary action. You DON'T need to get profile after creation. Profile is accessible from "currentProfile" property

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

setp(profileData, publicProfileData, rating, mmr, wlRate, ver, callback)

Fully set(rewrite) one or more root nodes. Not that I will poke you if you'll use this method more than once!

Parameters

Name Type Description
profileData

{Object} - a schema less object representing main profile data

publicProfileData

{Object} - a schema less public part - only part that available for discovery by other players

rating

{Number} - int used for matchmaking

mmr

{Number} - int used for matchmaking

wlRate

{Number} - int used for matchmaking

ver

{Number} - int representing version of particular profile. Once a while client will update and you'll need to mutate profile as far. "ver" property will help not to lost

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

update(profileData, publicProfileData, rating, mmr, wlRate, ver, callback)

More tolerated method for keeping data in profile. "publicData" and "publicProfileData" should be presented as 1-level key-value map where key is path(separated with dots) and value is the value. It will not fully rewrite root nodes but just change some according to these keys. Arguments "rating", "mmr", "wlRate" and "ver" mods the same way.

Parameters

Name Type Description
profileData

{Object} - a schema less object representing main profile data

publicProfileData

{Object} - a schema less public part - only part that available for discovery by other players

rating

{Number} - int used for matchmaking

mmr

{Number} - int used for matchmaking

wlRate

{Number} - int used for matchmaking

ver

{Number} - int representing version of particular profile. Once a while client will update and you'll need to mutate profile as far. "ver" property will help not to lost

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getPublic(targetHumanId, callback)

Just get someone's publicProfileData

Parameters

Name Type Description
targetHumanId

{Number} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API holding chats mechanism

Returns

Void

enterChatGroup(header)

Creates new chat group abstract object represented as GroupChat class instance. This class emits "message" event once new message or old message appears. It doesn't store messages after emit so you have to manage it by your self and sort them by sequence number.

Parameters

Name Type Description
header

{String} - a user-defined header that will be visible for communicating

Returns

GroupChat

  • returns promise if no callback provided

constructor()

A section of API host all leaderboards/records related: getting, setting and updating

Returns

Void

postRecord(value, intoSegment, callback)

Post a record into some segment(segments are white listed at Gbase configurations). All new posts in same segment will overwrite each other.

Parameters

Name Type Description
value

{Number} - positive int

intoSegment

{String} - string, default="def"

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getSelfRecord(fromSegment, callback)

Get self record from some segment. Self titled

Parameters

Name Type Description
fromSegment

{String} - string, default="def"

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getLeaderboardOverall(fromSegment, skip, limit, callback)

List leaders from some segment. Use arguments "skip" and "limit"(maximum 20) for pagination.

Parameters

Name Type Description
fromSegment

{String} - string, default="def"

skip

{Number} - int, min 0

limit

{Number} - int, min 1 max 20

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

removeSelfRecord(fromSegment, callback)

Remove player's record from some segment

Parameters

Name Type Description
fromSegment

{String} - string, default="def"

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

refreshVkFriendsCache(friendsArray, callback)

Before taking leaders among social friends you need to tell Goblin backend about your friends. It does't use any social SDK to get your friends by itself hence it's on your side.

Parameters

Name Type Description
friendsArray

{Array} - just an array of your friends' IDs

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

refreshOkFriendsCache(friendsArray, callback)

Before taking leaders among social friends you need to tell Goblin backend about your friends. It does't use any social SDK to get your friends by itself hence it's on your side.

Parameters

Name Type Description
friendsArray

{Array} - just an array of your friends' IDs

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

refreshFbFriendsCache(friendsArray, callback)

Before taking leaders among social friends you need to tell Goblin backend about your friends. It does't use any social SDK to get your friends by itself hence it's on your side.

Parameters

Name Type Description
friendsArray

{Array} - just an array of your friends' IDs

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getSomeonesRating(targetHumanId, fromSegment, callback)

To get someone's rating. Just a simple method to retrieve rating by providing existing human-ID.

Parameters

Name Type Description
targetHumanId

{Number} - self titled

fromSegment

{String} - self titled

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getLeadersWithinFriends(fromSegment, skip, limit, callback)

A special method to get leaders only among your social friends. It'll determine your social platform if you logged before. A very need to provide list of your friends first using methods "refresh*FriendsCache". If no friends on Goblin backend you'll get just positive response without any data. A friends cache lives approximately for 1 week(configured on backend). So just try to refresh your friends once a while but not too often.

Parameters

Name Type Description
fromSegment

{String} - self titled

skip

{Number} - pagination skip (from 0 to infinity)

limit

{Number} - pagination limit (from 1 to 20)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API holding matchmaking as a simple search without actual play

Returns

Void

matchPlayer(fromSegment, strategy, rangesOrDetails, callback)

Matchmaking - is a mechanism to pick some player to do the work with. Mostly to play with but you can interpret it as a search. Searching done by rating, picking the appropriate opponent by some rating value from some segment. All the data is up to you. In return you will get the Human-ID

Parameters

Name Type Description
fromSegment

{String} - self titled

strategy

{String} - if backend is configured to receive client-defined strategy, you can pick one from two available: GbaseApi.MATCHMAKING_STRATEGIES.BY_RATING and GbaseApi.MATCHMAKING_STRATEGIES.BY_LADDER

rangesOrDetails

{GbaseRangePicker || Object} - an instance with ranges of search. See test examples. Or any data to transfer if matchmaking is authoritarian

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

matchBot()

Not tested not documented yet

Returns

Void

constructor(fb, vk, ok, gClientId, gClientSecret, haveProfile)

A class holding all account related information. You can get it through API: GbaseAPI.currentAccount

Parameters

Name Type Description
fb

{String} - Facebook ID

vk

{String} - VK.com ID

ok

{String} - OK.ru ID

gClientId

{String} - internal login string

gClientSecret

{String} - internal secret/password string

haveProfile

{boolean} - whether this account has any single profile

Returns

Void

constructor(message, code, details)

A class to represent standard Gbase API error

Parameters

Name Type Description
message

{String} - message string

code

{Number} - unique code of error

details

{Object} - optional any-schema details

Returns

Void

constructor(head, nRandom)

A chain-call range builder object for matchmaking

Parameters

Name Type Description
head

{String} - Any range header string

nRandom

{Number} - Amount of bunch of appropriate opponents to randomly pick among

Returns

Void

range(from, to)

Sets yet another range

Parameters

Name Type Description
from

{Number} - a from value

to

{Number} - a to value

Returns

GbaseRangePicker

  • this

constructor(isOk, details)

Standard Gbase API response

Parameters

Name Type Description
isOk

{boolean} - whether done okay

details

{Object} - optional any-schema details

Returns

Void

constructor()

A section of API holding simplified PvE mechanism

Returns

Void

begin(beginParams, callback)

Pve is a set of acts programmed with 3 cloud functions: "pveInit", "pveAct" and "pveFinalize". Fist to are called directly from client and the last one is called automatically by decision of "pveAct" cloud function. Possible to pass any params to "pveInit" cloud function.

Parameters

Name Type Description
beginParams

{Object} - any plain object will be accessed on pveInit

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

act(actParams, callback)

An action or turn of PvE cycle. Backed with "pveAct" cloud function which can finalize pve cycle and call "pveFinalize" cloud function. The same way some params can be passed.

Parameters

Name Type Description
actParams

{Object} - any plain object will be accessed on pveAct

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

listBattles(skip, limit, callback)

Pve cycle will produce battle journal entry. It's made by calling function "appendSelfBattleJournalPve" from cloud function "pveFinalize". It'll contain some details on battle plus schema-less data from cloud code programmer.

Parameters

Name Type Description
skip

{Number} - pagination skip

limit

{Number} - pagination limit

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A pvp instance produced by {GbasePvpApi}. It emits the next events: "progress"(representing connection progress, providing progress message), "begin"(representing a start of gameplay. You can start your game after that), "error"(on any errors), "direct-message"(on direct message), "turn-message"(on turn message), "model"(providing an information about model. Usually after reconnection), "paused"(when game went on pause), "unpaused"(when game returns from pause), "sync"(representing need to sync your local model or state with backend's. Not a frequent but usually if game is paused and client thinks that you lost some messages), "finish"(representing finish of pvp match. GbasePvp instance is now done)

Returns

Void

doConnect(payloadObject)

Necessary action starting process of connection till "begin" event.

Parameters

Name Type Description
payloadObject

{Object} - A payload that model will be built with. This data will get into cloud function "pvpGeneratePayload"

Returns

Void

myPing()

Returns

Number

  • My ping in ms

opponentPing()

Returns

Number

  • Opponent's ping in ms

isPaused()

Returns

boolean

  • Whatever gameplay paused now

opponentPayload()

Returns

object

  • Opponent's payload that was built with cloud function "pvpGeneratePayload" or provided directly by him.

startTimestamp()

Returns

Number

  • A timestamp of gameplay's start at UTF-0

randomSeed()

Returns

Number

  • A random seed used to produce random values with Mersenne Twister

meIsPlayerA()

Returns

boolean

  • Whatever you are player A

sendTurn(turnMessage)

Send turn message to your opponent. It will get into cloud function "pvpTurnHandler" if presented. The idea of turn messages is that all they proceed in strict order with queue and directed to modify model. It is good practice to not to send turn messages more frequently than once per second. Message should be an object

Parameters

Name Type Description
turnMessage

{Object} - a message to send

Returns

Void

sendDirect(directMessage)

Send direct message to your opponent. It will be resend to him directly without queue, modification of model or calling any cloud function. It makes this type of messages the best way to hertz real-time gameplay, but the good practice will be to not to send this type of messages more frequently than 15 times per second. Message should be an object

Parameters

Name Type Description
directMessage

{Object} - a message to send

Returns

Void

forceDestroyClient()

Destroys pvp-client and emits "finish" event. Your opponent will be paused some time but later see "finish" event with message of automatic game over(or dead pair)

Returns

Void

constructor()

A section of API holding everything needed to start PvP with real player or fictive opponent

Returns

Void

checkBattleNoSearch(callback)

Player's matchmaking and pvp state is exclusive hence player can't play a few pvps at once. If you faced client crash and restart you should run this method to check whatever player was at pvp before crash. In response you'll get a status and pvp data if has. Provide this pvp data into beginOnAddressAndKey method to continue pvp.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

dropMatchmaking(callback)

Useful service method to force clean all matchmaking data. You can call it every time after proper finishing yet another pvp.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

withOpponent(fromSegment, strategy, rangesOrDetails, timeLimitSec, callback)

Search and begin pvp 1 versus 1. The gameplay will be encapsulated into "response.pvp" value as {GbasePvp}

Parameters

Name Type Description
fromSegment

{String} - ratings segment to search among

strategy

{String} - if backend is configured to receive client-defined strategy, you can pick one from two available: GbaseApi.MATCHMAKING_STRATEGIES.BY_RATING and GbaseApi.MATCHMAKING_STRATEGIES.BY_LADDER

rangesOrDetails

{GbaseRangePicker || Object} - an instance with ranges of search. See test examples. Or any data to transfer if matchmaking is authoritarian

timeLimitSec

{Number} - limit searching time in seconds. No guarantee that limit will be accurately equal to provided value because process is abrupt

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

withBotOpponent(rangesOrDetails, callback)

Begin gameplay versus bot profile. Need backend to be configured with bots

Parameters

Name Type Description
rangesOrDetails

{GbaseRangePicker || Object} - an instance with ranges of search. See test examples. Or any data to transfer if matchmaking is authoritarian

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

stopSearchingForOpponent()

Stops search No guarantee that limit will be accurately at exact moment because process is abrupt

Returns

beginVersusSelf(targetHumanId, callback)

Start gameplay player versus self based on pvp framework. Pipeline is the same and all messages will return to you. It's useful to use coupled with cloud functions.

Parameters

Name Type Description
targetHumanId

{Number} - some Human ID be provided to "pvpGeneratePayload" cloud function. Used to imitate gameplay versus some target opponent without his participate

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

beginOnAddressAndKey(pvpRoomData, callback)

Continue pvp gameplay with some provided data. You can get it with method "checkBattleNoSearch"

Parameters

Name Type Description
pvpRoomData

{Object} - pvp data from "checkBattleNoSearch" method response

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

battlesList(skip, limit, onlyAuto, callback)

Pvp gameplay may produce battle journal entry. It's made by calling function "appendBattleJournalPvp" from cloud function "pvpGameOverHandler" or "pvpAutoCloseHandler". It'll contain some details on battle plus schema-less data from cloud code programmer.

Parameters

Name Type Description
skip

{Number} - pagination skip

limit

{Number} - pagination limit

onlyAuto

{boolean} - list only entries produced from cloud function "pvpAutoCloseHandler"

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API holding mechanism of working with social networks VK.com and OK.ru

Returns

Void

vkListPurchases(skip, limit, callback)

Goblin backend can receive in-application purchases through "purchase service callback" that being contacted by VK.com itself. All of them are persisted and you can list them

Parameters

Name Type Description
skip

{Number} - pagination skip

limit

{Number} - pagination limit

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

vkConsumePurchase(purchaseNum, callback)

Mark purchase as consumed. Purchases itself do nothing for player hence you should manage it on client-side. Consume it and make some profile modifications(add gold or crystals). Consuming itself is atomic otherwise you'll get a legit logic error with index 179. Remember that two different requests for consuming and profile modification are not atomic so you need to implement some guarantees.

Parameters

Name Type Description
purchaseNum

{Number} - num of particular purchase you can get from listing

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

okListPurchases(skip, limit, callback)

Goblin backend can receive in-application purchases through "purchase service callback" that being contacted by OK.ru itself. All of them are persisted and you can list them

Parameters

Name Type Description
skip

{Number} - pagination skip

limit

{Number} - pagination limit

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

okConsumePurchase(purchaseNum, callback)

Mark purchase as consumed. Purchases itself do nothing for player hence you should manage it on client-side. Consume it and make some profile modifications(add gold or crystals). Consuming itself is atomic otherwise you'll get a legit logic error with index 575. Remember that two different requests for consuming and profile modification are not atomic so you need to implement some guarantees.

Parameters

Name Type Description
purchaseNum

{Number} - num of particular purchase you can get from listing

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API holding tickets mechanism

Returns

Void

sendTicket(receiverHumanId, header, payload, callback)

Send non-social ticket to some player through providing his human-ID. Ticket is a form of communication which helps you to send some schema-less data to players. Using this feature you can build trading or presents system. Ticket have limited life time configured on backend side.

Parameters

Name Type Description
receiverHumanId

{Number} - self titled

header

{String} - a user-defined header that will be visible for communicating

payload

{Object} - all the data you consider to provide

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

sendTicketVk(receiverVkId, header, payload, callback)

Send ticket to some player linked with VK.com through providing his VK.com ID. Ticket is a form of communication which helps you to send some schema-less data to players. Using this feature you can build trading or presents system. The ticket will be available for player even if he is not yet linked with VK.com(or if there is no such player yet). After signing up player anyway will receive this ticket. Ticket have limited life time configured on backend side.

Parameters

Name Type Description
receiverVkId

{String} - self titled

header

{String} - a user-defined header that will be visible for communicating

payload

{Object} - all the data you consider to provide

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

sendTicketOk(receiverOkId, header, payload, callback)

Send ticket to some player linked with OK.ru through providing his OK.ru ID. Ticket is a form of communication which helps you to send some schema-less data to players. Using this feature you can build trading or presents system. The ticket will be available for player even if he is not yet linked with VK.com(or if there is no such player yet). After signing up player anyway will receive this ticket. Ticket have limited life time configured on backend side.

Parameters

Name Type Description
receiverOkId

{String} - self titled

header

{String} - a user-defined header that will be visible for communicating

payload

{Object} - all the data you consider to provide

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

sendTicketFb(receiverFbId, header, payload, callback)

Send ticket to some player linked with Facebook through providing his Facebook ID. Ticket is a form of communication which helps you to send some schema-less data to players. Using this feature you can build trading or presents system. The ticket will be available for player even if he is not yet linked with VK.com(or if there is no such player yet). After signing up player anyway will receive this ticket. Ticket have limited life time configured on backend side.

Parameters

Name Type Description
receiverFbId

{String} - self titled

header

{String} - a user-defined header that will be visible for communicating

payload

{Object} - all the data you consider to provide

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

listSendedTickets(skip, limit, callback)

You can list your sended tickets with all useful information like ticket ID (tid), data and recipient's reaction on it.

Parameters

Name Type Description
skip

{Number} - pagination skip

limit

{Number} - pagination limit

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

listReceivedTickets(skip, limit, callback)

You can list your inbox of tickets with all useful information.

Parameters

Name Type Description
skip

{Number} - pagination skip

limit

{Number} - pagination limit

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

confirmTicket(ticketId, callback)

A conditional action of confirming non-social ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as confirmed on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

confirmTicketVk(ticketId, callback)

A conditional action of confirming VK.com ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as confirmed on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

confirmTicketOk(ticketId, callback)

A conditional action of confirming OK.ru ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as confirmed on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

confirmTicketFb(ticketId, callback)

A conditional action of confirming Facebook ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as confirmed on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

rejectTicket(ticketId, callback)

A conditional action of rejecting non-social ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as rejected on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

rejectTicketVk(ticketId, callback)

A conditional action of rejecting VK.com ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as rejected on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

rejectTicketOk(ticketId, callback)

A conditional action of rejecting OK.ru ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as rejected on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

rejectTicketFb(ticketId, callback)

A conditional action of rejecting Facebook ticket. It will do nothing special to interlocutors but you can base your domain logic on this confirm/reject reaction. A ticket will be marked as rejected on backend and both participants will see it.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

dischargeTicket(ticketId, callback)

Sender can discharge ticket - basically cancel it while it is not confirmed or rejected. Be ready to get a logic error with index 266 - it means that no ticket meets requirements, it was confirmed or rejected, been discharged previously or just unknown ticket ID. Ticket will be removed immediately.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

dismissTicket(ticketId, callback)

Sender to close rejected ticket. No affect on player data unless you'll implement it by yourself. Be ready to get a logic error with index 271 - it means that no ticket meets requirements, it was not rejected, been dismissed previously or just unknown ticket ID. Ticket will be removed immediately.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

releaseTicket(ticketId, callback)

Sender to close confirmed ticket. No affect on player data unless you'll implement it by yourself. Be ready to get a logic error with index 276 - it means that no ticket meets requirements, it was not confirmed, been released previously or just unknown ticket ID. Ticket will be removed immediately.

Parameters

Name Type Description
ticketId

{Number} - you can receive this parameter on callback for sending and on listing("tid" node)

callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

constructor()

A section of API holding various utils

Returns

Void

getServerTime(callback)

A simple method returns local server time. Commonly it's UTC 0.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

getSequence(callback)

A simple method returns current session request sequence.

Parameters

Name Type Description
callback

{Function} - standard callback(GbaseError err, GbaseResponse response)

Returns

Promise

  • returns promise if no callback provided

serverTimestampToLocal(theTimestamp)

A simple method to transform server-side timestamp to local considering different timezones

Parameters

Name Type Description
theTimestamp
  • self-titled

Returns

Number

  • transformed timestamp

purchaseValidation()

Not tested, not documented, yet!

Returns

Void