# 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 | Types | Description |
---|---|---|
functionName |
|
- string |
argumentsToTransfer |
|
- any object |
callback |
|
- standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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 |
# dropCache()
This asset uses a cache engine to store Gbase credentials automatically. Use this method to force clear the cache.
# 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.
# 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 | Types | Description |
---|---|---|
tokenFromFb |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
tokenFromOk |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
tokenFromVk |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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) |
# 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
# e(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 | Types | Description |
---|---|---|
gbaseIdOrLogin |
|
{String} - self titled |
gbaseSecretOrPassword |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# eAnon(callback)
Anonymous signing up. You will get gClientId and gClientSecret in response - save it and use for further signing ins.
Parameters
Name | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# eCustomCredentials(gbaseLogin, gbasePassword, callback)
Signing up similar to anonymous but you provide login and password by your self.
Parameters
Name | Types | 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) |
# FbProfile(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 | Types | Description |
---|---|---|
tokenFromFb |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
tokenFromFb |
|
{String} - self titled |
noNewProfile |
|
{boolean} - to create or not new profile |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
tokenFromOk |
|
{String} - self titled |
noNewProfile |
|
{boolean} - to create or not new profile |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
tokenFromVk |
|
{String} - self titled |
noNewProfile |
|
{boolean} - to create or not new profile |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# OkProfile(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 | Types | Description |
---|---|---|
tokenFromOk |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# VkProfile(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 | Types | Description |
---|---|---|
tokenFromVk |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# getPublic(targetHumanId, callback)
Just get someone's publicProfileData
Parameters
Name | Types | Description |
---|---|---|
targetHumanId |
|
{Number} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | Description |
---|---|---|
header |
|
{String} - a user-defined header that will be visible for communicating |
# getLeaderboardOverall(fromSegment, skip, limit, callback)
List leaders from some segment. Use arguments "skip" and "limit"(maximum 20) for pagination.
Parameters
Name | Types | 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) |
# 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 | Types | 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) |
# getSelfRecord(fromSegment, callback)
Get self record from some segment. Self titled
Parameters
Name | Types | Description |
---|---|---|
fromSegment |
|
{String} - string, default="def" |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# getSomeonesRating(targetHumanId, fromSegment, callback)
To get someone's rating. Just a simple method to retrieve rating by providing existing human-ID.
Parameters
Name | Types | Description |
---|---|---|
targetHumanId |
|
{Number} - self titled |
fromSegment |
|
{String} - self titled |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
value |
|
{Number} - positive int |
intoSegment |
|
{String} - string, default="def" |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
friendsArray |
|
{Array} - just an array of your friends' IDs |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
friendsArray |
|
{Array} - just an array of your friends' IDs |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
friendsArray |
|
{Array} - just an array of your friends' IDs |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# removeSelfRecord(fromSegment, callback)
Remove player's record from some segment
Parameters
Name | Types | Description |
---|---|---|
fromSegment |
|
{String} - string, default="def" |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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 |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# constructor(fb, vk, ok, gClientId, gClientSecret, haveProfile)
A class holding all account related information. You can get it through API: GbaseAPI.currentAccount
Parameters
# constructor(message, code, details)
A class to represent standard Gbase API error
Parameters
Name | Types | Description |
---|---|---|
message |
|
{String} - message string |
code |
|
{Number} - unique code of error |
details |
|
{Object} - optional any-schema details |
# constructor(head, nRandom)
A chain-call range builder object for matchmaking
Parameters
Name | Types | Description |
---|---|---|
head |
|
{String} - Any range header string |
nRandom |
|
{Number} - Amount of bunch of appropriate opponents to randomly pick among |
# range(from, to)
Sets yet another range
Parameters
Name | Types | Description |
---|---|---|
from |
|
{Number} - a from value |
to |
|
{Number} - a to value |
# constructor(isOk, details)
Standard Gbase API response
Parameters
Name | Types | Description |
---|---|---|
isOk |
|
{boolean} - whether done okay |
details |
|
{Object} - optional any-schema details |
# 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 | Types | Description |
---|---|---|
actParams |
|
{Object} - any plain object will be accessed on pveAct |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
beginParams |
|
{Object} - any plain object will be accessed on pveInit |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
skip |
|
{Number} - pagination skip |
limit |
|
{Number} - pagination limit |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# doConnect(payloadObject)
Necessary action starting process of connection till "begin" event.
Parameters
Name | Types | Description |
---|---|---|
payloadObject |
|
{Object} - A payload that model will be built with. This data will get into cloud function "pvpGeneratePayload" |
# eApiInstance()
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)
# 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)
# isPaused()
# meIsPlayerA()
# myPing()
# opponentPayload()
# opponentPing()
# randomSeed()
# 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 | Types | Description |
---|---|---|
directMessage |
|
{Object} - a message to send |
# 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 | Types | Description |
---|---|---|
turnMessage |
|
{Object} - a message to send |
# startTimestamp()
# 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 | Types | 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) |
# beginOnAddressAndKey(pvpRoomData, callback)
Continue pvp gameplay with some provided data. You can get it with method "checkBattleNoSearch"
Parameters
Name | Types | Description |
---|---|---|
pvpRoomData |
|
{Object} - pvp data from "checkBattleNoSearch" method response |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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) |
# 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 | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# eApi()
A section of API holding everything needed to start PvP with real player or fictive opponent
# stopSearchingForOpponent()
Stops search No guarantee that limit will be accurately at exact moment because process is abrupt
# withBotOpponent(rangesOrDetails, callback)
Begin gameplay versus bot profile. Need backend to be configured with bots
Parameters
Name | Types | Description |
---|---|---|
rangesOrDetails |
|
{GbaseRangePicker |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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 |
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) |
# e(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 | Types | Description |
---|---|---|
purchaseNum |
|
{Number} - num of particular purchase you can get from listing |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# e(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 | Types | Description |
---|---|---|
purchaseNum |
|
{Number} - num of particular purchase you can get from listing |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# es(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 | Types | Description |
---|---|---|
skip |
|
{Number} - pagination skip |
limit |
|
{Number} - pagination limit |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# es(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 | Types | Description |
---|---|---|
skip |
|
{Number} - pagination skip |
limit |
|
{Number} - pagination limit |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# eTicket(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 | Types | 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) |
# listReceivedTickets(skip, limit, callback)
You can list your inbox of tickets with all useful information.
Parameters
Name | Types | Description |
---|---|---|
skip |
|
{Number} - pagination skip |
limit |
|
{Number} - pagination limit |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | Description |
---|---|---|
skip |
|
{Number} - pagination skip |
limit |
|
{Number} - pagination limit |
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# 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 | Types | 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) |
# getSequence(callback)
A simple method returns current session request sequence.
Parameters
Name | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# getServerTime(callback)
A simple method returns local server time. Commonly it's UTC 0.
Parameters
Name | Types | Description |
---|---|---|
callback |
|
{Function} - standard callback(GbaseError err, GbaseResponse response) |
# serverTimestampToLocal(theTimestamp)
A simple method to transform server-side timestamp to local considering different timezones
Parameters
Name | Types | Description |
---|---|---|
theTimestamp |
|
- self-titled |
# testPvp.js()
To run this test and anyway play pvp you need to implement a few cloud function: pvpGeneratePayload.js: if(args.isA){ PvpResponse({ some: 'payload a' }); } else if(args.isBot){ PvpResponse({ some: 'payload b', alsoBot: true }); } else { PvpResponse({ some: 'payload b' }); }
pvpInitGameplayModel.js: PvpResponse({ plrA: args.payloadA, plrB: args.payloadB, plrAsq: 0, plrBsq: 0 });
pvpTurnHandler.js: var theEnd = ((args.theModel.model.plrAsq === 14 && args.isA) || (args.theModel.model.plrBsq === 14 && !args.isA)); if(args.isA){ args.theModel.model.plrAsq++; if(!theEnd){ if(args.theModel.model.plrB.alsoBot){ PvpMessageHandler(args.theModel, { oppsq: args.theModel.model.plrAsq, m: args.theMessage }); } else { PvpMessageHandler(args.theModel, undefined, { oppsq: args.theModel.model.plrAsq, m: args.theMessage }); } } } else { args.theModel.model.plrBsq++; if(!theEnd){ PvpMessageHandler(args.theModel, { oppsq: args.theModel.model.plrBsq, m: args.theMessage }); } } if(theEnd){ let finalMessage = { gameIsOver: true, finalm: { m: args.theMessage, asq: args.theModel.model.plrAsq, bsq: args.theModel.model.plrBsq } }; PvpMessageHandler(args.theModel, finalMessage, finalMessage); }
pvpConnectionHandler.js: PvpResponse({ isA: +args.isA, playerTurnA: args.playerTurnA, playerTurnB: args.playerTurnB, mdl: { randomSeed: args.randomSeed, startTs: args.startTs, model: args.theModel } });
pvpDisconnectionHandler.js: PvpDisconnectionHandler({ isA: +args.disconnectedIsA, playerTurnA: args.playerTurnA, playerTurnB: args.playerTurnB, theModel: args.theModel });
pvpCheckGameOver.js: PvpResponse((args.theModel.model.plrAsq === 15 || args.theModel.model.plrBsq === 15) ? { gameIsOver: true } : null);
pvpGameOverHandler.js: appendBattleJournalPvp({ hello: 'world' }); PvpResponse();
pvpAutoCloseHandler.js: appendBattleJournalPvp({ looo: 'sers', lagA: args.lagA, lagB: args.lagB }, true); PvpAutoDefeatResponse({ loooser: 'a' }, { loooser: 'b' });