How to get turnbase room properties in server side

+1 vote
sorry if this is duplicate question as I have tried search it here, but I can't find it
so here is my question...

I am making a game using appwarp s2 API using AS3.
I am trying to create turn based room

this is my code for creating room by client side

var RoomProperties:Object;
RoomProperties.Mode = "Normal";
client.createTurnRoom("Normal by " + DisplayName, DisplayName, 4, RoomProperties, 10);

so how to get the RoomProperties in server side? As in IRoom.getProperties is returning Map, and I am new to Java here. This is what I want to do with room properties

@Override
    public void handleCreateRoomRequest(IUser user, IRoom room, HandlingResult result)
    {
        if(room.getProperties.Mode == "Normal")
                 room.setAdaptor(new RoomNormal(izone, (ITurnBasedRoom)room));
        else if(room.getProperties.Mode == "Hard")
                 room.setAdaptor(new RoomHard(izone, (ITurnBasedRoom)room));
    }
asked Aug 13, 2015 in AppWarpS2 by Propheus (32 points)

1 Answer

+1 vote
 
Best answer

Hi,

You can use following java code snippet to create Room, based on room properties.

 String gameMode=(String) room.getProperties().get("mode");
         if(gameMode.equals("Normal")){
                room.setAdaptor(new RoomNormal(izone, (ITurnBasedRoom)room));
         }
         else if(gameMode.equals("Hard")){
             room.setAdaptor(new RoomHard(izone, (ITurnBasedRoom)room));
         }

Let me know if it helps.

Thanks & Regards

Vishnu Garg

answered Aug 13, 2015 by Vishnu Garg (674 points)
selected Aug 14, 2015 by Propheus
sorry, it doesn't shows error so I thought it was correct
The server is crash without throwing any error, and after I trace it...

String gameMode=(String) room.getProperties().get("Mode");
System.out.println(gameMode);

it shows null
Can you please share source code of the Room Creation on client side.
client side CreateRoom

public static function CreateRoom(mode:String):void
{
    var RoomProperties:Object = new Object();
    RoomProperties.Mode = mode;
    if(mode == "Normal")
        client.createTurnRoom("Normal by " + DisplayName, DisplayName, 4, RoomProperties, 10);
    else if(mode == "Hard")
        client.createTurnRoom("Hard by " + DisplayName, DisplayName, 4, RoomProperties, 10);
}

I call it using
    CreateRoom("Normal");

in server side
    @Override
     public void handleCreateRoomRequest(IUser user, IRoom room, HandlingResult result)
     {
        System.out.println(room.getName()); //this returns correctly
       
        String gameMode=(String) room.getProperties().get("Mode");
        System.out.println(gameMode); //this returns null
     }
can you please print   System.out.println(room.getProperties().toString()) to check what kind of properties you are getting actually
it prints
{}

seems like the object is not sent

I also tried
client.createTurnRoom("Normal by " + DisplayName, DisplayName, 4, {Mode:mode, test:"test"}, 10);
but no luck either
Hi,
I have updated the SDK which you can download from here(https://www.dropbox.com/s/qmem9hwu7aw1864/AppWarpLibS2.swc?dl=0). Please download and try. Let me know if the problem continues.
Thanks.
I get error "interface method onInvokeRoomRPCDone in interface RoomRequestListener not implemented by class RequestListener"

seems like it has new function right now, and I can't see the parameters in adobe flash builder 4.7
what is the parameter to override it?
nvm, I found the parameters here
http://blogs.shephertz.com/2014/04/14/using-rpcs-in-unity-appwarps2/

and now, roomProperties works fine
thank you

now
         System.out.println(room.getProperties().toString());
shows
         {Mode=Normal}
We have added RPC API in SDK so you need to implement those callback as well.
In case of any more furher query feel free to ask us.
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
...