Cloud Code

General cloud code discussions...

28 Topics 103 Posts
  • Filter online players in Matchmaking

    Solved
    8
    0 Votes
    8 Posts
    300 Views

    Ciao @Paul-Winterhalder ,

    yes there is not much else to add, except perhaps the fact that the CompleteMatch is sent at the end of the game. Instead, AbandonMatch is sent if one of the players abandons the game prematurely.

    Thanks for the support! ­čÖé

  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    5 Views
  • 0 Votes
    5 Posts
    341 Views

    There is a global list of reason codes here - https://docs.braincloudservers.com/api/appendix/reasonCodes

  • Cloud code retries, error handling question

    Unsolved
    2
    0 Votes
    2 Posts
    184 Views

    A good way to handle failure besides retrying in code, is to schedule another script to run 1 minute later that will basically repeat the same action.

  • Lobby creation/deletion events in CloudCode

    Unsolved
    13
    0 Votes
    13 Posts
    594 Views

    Hi Alessio,

    I have a suggestion.

    Why not create a global chat channel called "lobbyListeners".

    Then - when a user is viewing the lobbies - have them connect to and listen to the lobbyListeners channel.

    Then you don't need to maintain a global entity at all. Whenever you create a lobby or delete it - send an event to lobbyListeners - and it will automatically send it to everyone who has registered for the channel.

    Would that work? (or is there a part of your use case that I am missing?)

    Paul.

  • 0 Votes
    3 Posts
    284 Views

    @JasonL Thanks, I ended up with this cloudCode:

    isForceCreate = String(data.callingMessage.forceCreate) == "true"; isNewUser = String(data.message.newUser) == "true"; var response = {}; response.status = 200; response.data = data.message; if (isForceCreate && isNewUser) { var min = 10000000, max = 999999999 prefix = ["player", "user", "member"] const num = Math.floor(Math.random() * (max - min + 1)) + min; const pre = prefix[Math.floor(Math.random() * prefix.length)]; var defaultPlayerName = pre + String(num); var playerStateProxy = bridge.getPlayerStateServiceProxy(); // We are changing the player name on the server. playerStateProxy.updatePlayerName(defaultPlayerName); // And in this API Call's return data. response.data.playerName = pre + String(num); } response; //return the object

    This works just the way I need

  • bridge.include doesn't exists

    2
    0 Votes
    2 Posts
    212 Views

    Hey, there must be some syntax error in your script, would you be able to provide your script code here?

  • HTTP Client API - DELETE calls

    3
    0 Votes
    3 Posts
    225 Views

    Delete call update and everything is working now. Thanks!

  • 0 Votes
    1 Posts
    156 Views
    No one has replied
  • 0 Votes
    2 Posts
    219 Views

    I posted this almost 13 days ago with zero answers, so I took some time to look through a bunch of documentation and did a ton of trial and error. Please Braincloud for the love of god add this to your API.

    Rhino does not handle Arrays the way that other coding languages do.

    I figured it out, unlike most arrays that return an array after you call push- Rhino returns the new length. So if you call push, don't set it's value.

    var copyArray = []; //I assume this line tells it to be an array for (var i = 0; i < postResult.data..length; i++) { copyArray[i] = postResult.data[i]; //arrays do not behave like .Net arrays, you can change length without initializing, so you just set each index to the index of the array you're copying } copyArray.push(variableToAdd); //Do NOT set this as the value of your array, the push method returns an int (length of array) NOT an array! //you probably dont need to call push at all to add to the array as shown in the for loop above if you already know your length or want a specific length

    Then just set your value to the variable, like this

    var entityData = { "variableName": copyArray }; //No need to call Array(copyArray) or any of the prototype. slice stuff. If you call Array() you'll just nest the array a second time.

    Use this page for further info on functions you can do with arrays.

  • 0 Votes
    1 Posts
    172 Views
    No one has replied
  • 2 Votes
    6 Posts
    271 Views

    Well - the new release isn't out yet - it's just a Release Candidate.

    https://github.com/mozilla/rhino/releases

    That said - we are very happy to see the progress - since it has been over a year since 1.7.13 was released!

    Hopefully soon!

  • 0 Votes
    1 Posts
    170 Views
    No one has replied
  • Using numbers as JSON key.

    5
    0 Votes
    5 Posts
    260 Views

    @JasonL
    Thank you!!

  • 0 Votes
    3 Posts
    244 Views

    Hi Reza, a simple workaround I would recommend is using our atomic methods, such as IncrementGlobalStats, to form the field values with the returned value of that method and some other characters you selected. (defined a global statistic ahead of time, call IncrementGlobalStats() get the returned current value of the global statistic, e.g. 123, then combine with the name you selected to a unique name, such as name_123)

  • 0 Votes
    8 Posts
    294 Views

    @Travis-Brown-John You can create them manually from the Monitoring menu.

    Monitoring | Global Monitoring | Global Entities.

    Note - if your app is live, you need to unlock it first. You'll see a bit [+] button to the right of the Bulk actions drop-down.

    Good luck!

    Paul.

  • Segmentation APIs

    4
    0 Votes
    4 Posts
    279 Views

    Hi @Alexandru ,

    We've just officially added the Segment call you're looking for to brainCloud 4.55 - which is targeted for release in the next ~30 days...

    Updated Roadmap here - https://portal.productboard.com/braincloud/1-braincloud-baas-roadmap

    Paul.

  • 0 Votes
    3 Posts
    243 Views

    Edit . you can get all custom entities for the current user with the query

    { "entityType": "[entitytype]", "ownerId": "[profileId]", "context": { "pagination": { "rowsPerPage": 50, "pageNumber": 1 }, "searchCriteria": { // other search criteria here }, "sortCriteria": { "createdAt": 1 } } }
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    7 Views
    No one has replied