How to use RoomId (string) from Json Data such as {"Room":"12345"} to add virtual user into room?

0 votes

Hi,

I am developing trivia game in which 6 users can play game in 1 room. I have implemented it in objective c but now I want to create virtual user if room has not 6 users in 30 seconds.

I have created jar file and deployed it.Now I want to add virtual users to the room with Id I am passing from objective c using customCodeService. I am fetching room id using following code in android:

 JSONObject body = request.getBody();  

 // Build Log Service For logging in Your Code  

  LogService logger = sp.buildLogService(); 

body.getString("Room").toString()

Now what i want is add virtual user to the room with Id and zone I am getting through body.getString(). I have used following code but getting error in room and zone.

IUser user = (IUser) new VirtualUser("Bot"+i, (Room)room, (Zone)zone); 

room.addUser(user, true);

System.out.println("Adding Bot User : "+user.getName());

 

So How can I create ITurnBasedRoom and IZone from the ids(string) ?

asked Jan 11, 2017 in AppWarpS2 by contact (16 points)

1 Answer

0 votes

Hi Contact,

Greetings from ShepHertz !!!!

Its much confusing  for us to understand your useCases and how you are achieving this. Please share the client server architecture in brief  so that We can help in the same.

I have also few queries like :

  1. Which Jar you are deploying Custom Code or AppWarpS2 ? How you are deploying the same?
  2. Where you are creating a Virtual User.

App42 and AppWarp are separate product, You only create Virtual User on AppWarpS2 server. You can create turnBase room from client.

Let me know the details.

 

Regards

Vishnu Garg

 

 

 

answered Jan 11, 2017 by Vishnu Garg (674 points)
Hi Vishnu,

Que 1. Which Jar you are deploying Custom Code or AppWarpS2 ? How you are deploying the same?
Ans: I'm deploying custom code jar and executing it from ios using following code:
CustomCodeService *customCodeService = [App42API buildCustomCodeService];
    NSString *name = @"TestWithParams"; //App42CustomCodeTest
    NSDictionary *requestBody = [NSDictionary dictionaryWithObjectsAndKeys:@"Room",@"Test1", nil];
    [customCodeService runJavaCode:name requestBody:requestBody completionBlock:^(BOOL success, id responseObj, App42Exception *exception) {
        NSString *jsonResponse = [responseObj toString];
        NSLog(@"jsonResponse == %@",jsonResponse);
    }];

Ques 2: Where you are creating a Virtual User.
Ans : I have written code for creating virtual user in java and deployed jar file of that class in custom code

IUser user = (IUser) new VirtualUser("Bot"+i, (Room)room, (Zone)zone);

room.addUser(user, true);

System.out.println("Adding Bot User : "+user.getName());


And how can we deploy jar in AppWarps2 server? In AppWarps2 admin dashboard: http://appwarps2.shephertz.com/AdminDashboard/ there is no tab for uploading jar.

Thanks
As AppWarpS2 is different please don't mix it Custom Code, Custom Code provide you to write code on server which can we access through API.
AppWrapS2 is an extended version of AppWarp where you can write game logic you can use App42 SDK for calling custom Code API in AppWarpS2 but you can't use AppWarp in Custom Code.

You can deploy your AppWarpS2 on GPaaS.
You can refer the http://app42paas.shephertz.com/dev-center/gpaas/
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
...