Cloud Code

General cloud code discussions...

34 Topics 141 Posts
  • HTTP Client API - DELETE calls

    3
    0 Votes
    3 Posts
    925 Views

    Delete call update and everything is working now. Thanks!

  • bridge.include doesn't exists

    2
    0 Votes
    2 Posts
    788 Views

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

  • 0 Votes
    3 Posts
    1k 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

  • Lobby creation/deletion events in CloudCode

    Unsolved
    13
    0 Votes
    13 Posts
    3k 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.

  • Cloud code retries, error handling question

    Unsolved
    2
    0 Votes
    2 Posts
    792 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.

  • 0 Votes
    5 Posts
    1k Views

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

  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    5 Views
  • Filter online players in Matchmaking

    Solved
    8
    0 Votes
    8 Posts
    2k 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! 🙂

  • Webhook routes

    Solved
    12
    0 Votes
    12 Posts
    3k Views

    Cool. Thanks for sharing the solution here @devsleeper !

  • bridge.getCustomEntityServiceProxy()

    Unsolved
    5
    0 Votes
    5 Posts
    986 Views

    Hi @kinco-h - I assume (hope) you got the info you needed from our support folks?

    Hint - you access chat support by clicking on the "Ask Support" button in the top right-hand corner of the Design Portal...

    2024-12-04_09-07-57.png

  • "Player Location" custom session/matchmaking id

    Solved
    4
    0 Votes
    4 Posts
    1k Views

    Ah - perfect. Yeah - that sounds like a better option given the full requirements.

    Glad you found it... and welcome to brainCloud!

  • Recurring scheduled tasks?

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views

    We agree with that @antony - we'll get that request to the devs.

  • ScheduleRunScriptUTCv2 doesn't seem to work as expected?

    Solved
    7
    0 Votes
    7 Posts
    951 Views

    Cool - good to hear it. And once again: thanks for reporting it!

  • 0 Votes
    4 Posts
    239 Views

    Thanks for reaching out and for raising the question.

    At the moment, the VS Code extension does not support targeting or importing from a specific directory. Its primary purpose is to synchronize Cloud Scripts stored in brainCloud and provide a convenient way to edit them using standard VS Code workflows and tooling.

    We have created an internal task to review this limitation and discuss potential improvements to the extension so that it better supports directory-based workflows in the future.

    In the meantime, one practical workaround is to export your Cloud Scripts directly from the brainCloud portal. Once exported, all scripts can be reviewed locally. You can then organize them into a folder structure that mirrors your desired layout, including the use of subfolders and .ccjs files. From there, you can zip the contents and import them back into your app, which can significantly reduce the need for repetitive copy and paste actions across individual files.

    Please let us know if this approach works for your use case or if you have additional feedback on how you would like to see the extension evolve.