AppWarpS2 JoinRoomWithProperties error code 1

0 votes
Hi I'm using AppWarpS2 server with Unity. I can initialise the connectio with the following code:

WarpClient.initialize(GlobalContext.API_KEY, GlobalContext.HOST_NAME);
// Allow for some connection resiliency = 60 seconds
WarpClient.setRecoveryAllowance(60);
GlobalContext.warpClient = WarpClient.GetInstance();

Then I call connect with the following code:

WarpClient.GetInstance().Connect(GlobalContext.localUsername, "");

In ConnectionListiner onConnectionDone is SUCCESS and I then call:

WarpClient.GetInstance().JoinRoomWithProperties(GlobalContext.tableProperties);

To join the room but then I get a response back in ConnectionListiner with response code 1 (AUTH_ERROR)...?

My player is not being added to the game room and I don't know why, can you please help with this situation here?

 There is no other user connected at that time and my app is of the correct type! I'm running the server locally and the QuizZoneAdapter is registering the request handleAddUserRequest()!

Thanks
asked Nov 6, 2015 in Announcements by wiredvoltage (84 points)
edited Nov 6, 2015 by wiredvoltage

1 Answer

0 votes

Hi,

Can you please provide the code snippet of handleAddUserRequest() function that you are overriding on AppWarpS2 side.

It will help us to trace the exact problem you are facing.

Let me know.

Thanks

Vishnu Garg

 

answered Nov 6, 2015 by Vishnu Garg (674 points)
Hi Vishnu, here is the code:

     * Invoked when connect request is received from a client.
     *  
     * By default the user will be added to the zone and if user with the  
     * same name exists that user will be disconnected.
     *  
     * @param user the user who has sent the connect request.
     * @param authData the authdata passed in the connect request
     * @param result use this to override the default behaviour
     */
    @Override
    public void handleAddUserRequest(IUser user, String authData, HandlingResult result)
    {
        System.out.println("In handleAddUserRequest()");
        // Below method of finding user fb friend in zone is totally
        // slow and I will need to re-write
        try
        {
            /*If user had joined using his facebook account this function will make
             *list of friends those are playing this game in current zone
             */
            System.out.println("Add user request " + user.getName());
            if (!authData.equals(""))
            {
                user.setCustomData(authData);
                try
                {
                    JSONObject statObj = new JSONObject(user.getCustomData());
                    // Get list of user fb friends
                    List fbFriends = Utils.getFacebookFriends(statObj.getString("AccessToken"));
                    // Create a list of IUsers for fb friends
                    ArrayList<IUser> FBFriendsInMyZone = new ArrayList<IUser>();
                    // Create a list of users in this zone
                    Iterator zoneLstIterator = this.zone.getUsers().iterator();
                    // Loop for each user in this zone
                    while (zoneLstIterator.hasNext())
                    {
                        // Create a IUser object for each user in zone
                        IUser zoneUser = (IUser) zoneLstIterator.next();
                        // Get user fb id
                        String fbId = new JSONObject(zoneUser.getCustomData()).getString("FacebookId");
                        // Create an iterator for user fb friends from user fb firend list
                        Iterator lstIterator = fbFriends.listIterator();
                        // Loop for each user fb friend
                        while (lstIterator.hasNext())
                        {
                            // Check if the current zone user is user fb friend as we loop through
                            User fbuser = (User) lstIterator.next();
                            if (fbId.equals(fbuser.getId()))
                            {
                                // It is user fb friend so add them to our friend list
                                FBFriendsInMyZone.add(zoneUser);
                            }
                        }
                    }
                    // Create a JSON user array
                    JSONArray usersArray = new JSONArray();
                    // Loop for each user friend we found in zone
                    for (int i = 0; i < FBFriendsInMyZone.size(); i++)
                    {
                        JSONObject objPayload = new JSONObject();
                        // Add user fb friend name to JSONObject
                        objPayload.put("username", FBFriendsInMyZone.get(i).getName());
                        // Add user fb friend custom data and fb id to JSONObject
                        objPayload.put("facebookId", new JSONObject(FBFriendsInMyZone.get(i).getCustomData()).getString("FacebookId"));
                        // Add each user fb friend JSONObject to our JSONArray
                        usersArray.put(objPayload);
                    }
                    // Create byte array of user fb friend list
                    int Length = 40 + usersArray.toString().getBytes().length;
                    IoBuffer buf = IoBuffer.allocate(Length);
                    buf.setAutoExpand(true);
                    buf.put(QuizResponseCode.FBFRIENDLIST);
                    buf.putInt(usersArray.toString().getBytes().length);
                    buf.put(usersArray.toString().getBytes());
                    // Broadcast user fb friend list byte array to client
                    user.SendUpdatePeersNotification(buf.array(), false);
                }
                catch (Exception e)
                {
                }
            }
        }
        catch (Exception e)
        {
        }
    }


I have a native WP app that connects to the same game on server which works fine! I am currently working on developing the Unity version and dropping the WP only app when finished.

Thanks
On which platform you are facing this issue with Unity.
Hi Vishnu, the problem has been solved. Thanks for your help.

I found that both events that initialises the connection to AppWarpS2 server and then to connect were defined twice in the constructor, apologies I totally missed this as it happened when uploading scripts to BitBucket and they were not resolved on upload so they got duplicated!

Thanks
Let me know if more queries are concern. Thanks
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...