• Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums
G

Gavin Beard

@Gavin Beard
About
Posts
10
Topics
5
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

    Issue with Auth when running outside of Unity editor
  • G Gavin Beard

    Hi Franco,

    I am not sure the issue is anything to do with networking, it fully works from Unity editor and I think the error from brainCloud is potentially misleading.

    I am using Unity 2021.3.8f1

    After tracing it back tracing it back through, the error is being generated byBrainCloudComms.cs, specifically private void HandleResponseBundle(string jsonData), If I enable debugging and run on an iPhone, I get output of:

    19:22:40.664 #BCC RESPONSE - 21/04/2023 19:22:40
    {"packetId":0,"responses":[{"data":{"abTestingId":30,"lastLogin":1682102815319,"server_time":1682102815403,"refundCount":0,"timeZoneOffset":0.0,"experiencePoints":200,"maxBundleMsgs":10,"createdAt":1682102815302,"parentProfileId":null,"emailAddress":null,"experienceLevel":1,"countryCode":"GB","vcClaimed":0,"currency":{"coins":{"consumed":0,"balance":200,"purchased":0,"awarded":200}},"id":"b49b86a2-6b23-4467-8a8b-ab7208fa40f7","compressIfLarger":51200,"amountSpent":0,"previousLogin":null,"playerName":"player234147492","pictureUrl":null,"incoming_events":[],"sessionId":"e6r6fmaatt4u32891m6en7htct","languageCode":"en","vcPurchased":0,"isTester":false,"summaryFriendData":null,"loginCount":1,"emailVerified":true,"xpCapped":false,"profileId":"b49b86a2-6b23-4467-8a8b-ab7208fa40f7","newUser":"true","playerSessionExpiry":1200,"sent_events":[],"maxKillCount":11,"rewards":{"experiencePoints":200,"rewardDetails":{"xp":{"experienceLevels":[{"level":1,"rewards":{"experiencePoints":200,"currency":{"coins":200}}}],"experiencePoints":200}},"xpCapped":false,"currency":{"coins":{"consumed":0,"balance":200,"purchased":0,"awarded":200}},"experienceLevel":1,"rewards":{"experienceLevels":[1],"experiencePoints":200,"currency":{"coins":200}}},"statistics":{}},"status":200}]}
    false
    

    The function then tries to decode the json:

    JsonResponseBundleV2 bundleObj = DeserializeJsonBundle(jsonData);
    

    The next bit of output is then:

    19:22:40.666 #BCC Only objects with default constructors can be deserialized. (BrainCloud.Internal.JsonResponseBundleV2)
    UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    BrainCloud.BrainCloudClient:Log(String)
    BrainCloud.Internal.BrainCloudComms:DeserializeJsonBundle(String)
    BrainCloud.Internal.BrainCloudComms:HandleResponseBundle(String)
    BrainCloud.Internal.BrainCloudComms:Update()
    BrainCloud.BrainCloudClient:Update(eBrainCloudUpdateType)
    BrainCloudWrapper:RunCallbacks()
    BrainCloudWrapper:Update()
    
    Received an invalid json format response, check your network settings.
    

    So data is definitely making it back from the server, but then if I log in from Unity editor, the response from BrainCloud looks similar?

    {"packetId":0,"responses":[{"data":{"abTestingId":6,"lastLogin":1682102456093,"server_time":1682102456127,"refundCount":0,"timeZoneOffset":0.0,"experiencePoints":200,"maxBundleMsgs":10,"createdAt":1682102419336,"parentProfileId":null,"emailAddress":null,"experienceLevel":1,"countryCode":null,"vcClaimed":0,"currency":{"coins":{"consumed":0,"balance":200,"purchased":0,"awarded":200}},"id":"cd068c0b-d7f6-41de-85bd-8830631020e3","compressIfLarger":51200,"amountSpent":0,"previousLogin":1682102419345,"playerName":"kohatu918618012","pictureUrl":null,"incoming_events":[],"sessionId":"i405rjp0s9b3unisrfedpsem0b","languageCode":"en","vcPurchased":0,"isTester":false,"summaryFriendData":null,"loginCount":2,"emailVerified":true,"xpCapped":false,"profileId":"cd068c0b-d7f6-41de-85bd-8830631020e3","newUser":"false","playerSessionExpiry":1200,"sent_events":[],"maxKillCount":11,"rewards":{"rewardDetails":{},"currency":{},"rewards":{}},"statistics":{}},"status":200}]}
    

  • Issue with Auth when running outside of Unity editor
  • G Gavin Beard

    I've recent been testing a game within the Unity editor without issue, so decided to try and run it on device (Mac, iPhone and Android), however at this point anonymous auth seems to stop working with this error:

    Received an invalid json format response, check your network settings.
    GameManager:onAuthFailure(Int32, Int32, String, Object)
    BrainCloudWrapper:AuthFailureCallback(Int32, Int32, String, Object)
    

    Code:

    public void SetupPlayer(bool tryGameCentre = false)
      {
    
          if (!Bc.Client.IsAuthenticated())
          {
              Bc.AuthenticateAnonymous(new SuccessCallback(onAuthSuccess), new      FailureCallback(onAuthFailure));
          }
      }
    
        public void onAuthFailure(int status, int errorCode, string jsonError, object sender)
        {
            Debug.Log($"{jsonError}");
        }
    
        public void onAuthSuccess(string jsonResponse, object sender)
        {
            var response = JObject.Parse(jsonResponse);
    
            if (response == null)
            {
                Debug.Log("Error logging in");
                return;
            }
    
            currentUser = UserModel.FromJson(response["data"].ToString());
    
    #if UNITY_IOS
            Debug.Log("IOS RUNNING");
            StartCoroutine(RequestAuthorization());
    #endif
            GetGameList();
    
            UserAuthenticationSuccessful(currentUser.SessionId != null ? true : false);
    
        }
    

    this all works fine in the editor, it is only on device


  • Async match without opponent
  • G Gavin Beard

    @Paul-Winterhalder said in Async match without opponent:

    Hi,

    brainCloud currently offers two forms of matchmaking:

    Offline matchmaking - for async match (i.e. words with friends) or one-way multiplayer (i.e. class of clans) style games. Both of those multiplayer types require you to have an opponent to play against when the match starts.

    There is also online matchmaking - which uses our lobby system - which is suitable of any online / real-time sort of multiplayer.

    (That one doesn't require you to have an opponent in mind when the lobby starts... and the lobby can start a match via a relay or room server session right away...)

    That said - I get the feeling that you are talking about more of an async match scenario (i.e. not-necessarily-online multiplayer) - where the match can start before an opponent has been identified.

    Am I correct that that is the scenario you are wanting to target?

    It's an interesting approach - as there's a much lower chance of matching against another player who isn't going to respond in a timely manner.

    Let me know if I've got the scenario right and we'll give it some more thought...

    Paul.

    Hi Paul,

    Yes, you are correct. When a user starts a new game, it'd essentially see if someone has already started a game but has no opponent, If a match is found the second player will be added to the game and can then make their move. If no match is found that is awaiting a player, it'll create a new game, let player 1 make their move and then go "dormant" until a player two is ready.

    If you have ever used the turn based aspect of Apples Game Center turn based service, this is essentially how that works.


  • Async match without opponent
  • G Gavin Beard

    Hi,

    I am looking to replicate the functionality of match making in services like Apples Game Center, where by a user can create a new game, a check is done to see if there is anyone that has already started a match and submitted a move, and if that match has no opponent, it puts the new user in. At present in the brainCloud documents, it seems a match can only be created if you know the details of the opponent you want to start a match against.

    What would be the best patter to mimic this behaviour within BC (using unity)


  • Execute script when new user is registered
  • G Gavin Beard

    @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


  • Execute script when new user is registered
  • G Gavin Beard

    Hi,

    I'd like to create a script that is executed when a new user is registered, to assign a random player name if one is not present (something like player12243534) but am struggling with the docs to see where / how I can do this?

    Thanks


  • Authentication error - Unity iOS
  • G Gavin Beard

    Also getting the same error with "Sign In With Apple" when using the brainCloudWrapper.AuthenticateApple() method


  • Authentication error - Unity iOS
  • G Gavin Beard

    I can see in the documentation that reason code 40206 is "MISSING_IDENTITY_ERROR" and that it suggests maybe trying forceCreate?

    The iPhone crash is a bigger problem, as this can turn users away from the app pretty easily


  • Authentication error - Unity iOS
  • G Gavin Beard

    Hi all,

    I've been trying out brainCloud as a replacement for Game Center turn based matching but I've run into a problem.

    In my C# script I have a brainCloud Wrapper:

    public BrainCloudWrapper brainCloudWrapper;
    

    when the singleton it is attached to is initiated it runs the following:

        ```
    

    brainCloudWrapper = gameObject.AddComponent<BrainCloudWrapper>();
    brainCloudWrapper.Init();

    
    There is a simple button in a UI that calls the following:
    
            ```
            brainCloudWrapper.AuthenticateAnonymous(successCallback = (response, cbObject) =>
            {
                Debug.Log(string.Format("Success | {0}", response));
            },
            failureCallback = (status, code, error, cbObject) =>
            {
                Debug.Log(string.Format("Failed | {0}  {1}  {2}", status, code, error));
            });
    

    it runs in the editor but gives me:

    Failed | 202 40206 {"status_message":"Processing exception (message): Credentials missing for Profile Id.","reason_code":40206,"status":202}

    If I run it on my iPhone test device it causes a complete crash of the app with the following:

    JsonTypeCoercionException: Only objects with default constructors can be deserialized. (BrainCloud.Internal.JsonResponseBundleV2)
      at BrainCloud.JsonFx.Json.TypeCoercionUtility.InstantiateObject (System.Type objectType, System.Collections.Generic.Dictionary`2[System.String,System.Reflection.MemberInfo]& memberMap) [0x00000] in <00000000000000000000000000000000>:0 
      at BrainCloud.JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0 
      at BrainCloud.JsonFx.Json.JsonReader.Deserialize[T] (System.String value) [0x00000] in <00000000000000000000000000000000>:0 
      at BrainCloud.Internal.BrainCloudComms.HandleResponseBundle (System.String jsonData) [0x00000] in <00000000000000000000000000000000>:0 
      at BrainCloud.Internal.BrainCloudComms.Update () [0x00000] in <00000000000000000000000000000000>:0 
      at BrainCloud.BrainCloudClient.Update (BrainCloud.eBrainCloudUpdateType in_updateType) [0x00000] in <00000000000000000000000000000000>:0 
    

    Am I missing something from my setup, or in my code calls? it ran a few times without problem but seemed to generate a new user every time it ran which wasn't the expected behaviour (I assumed if it was same device it would use the already created anon. user)

    Any help is much appreciated

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users