using JoinRoomInRange in Smiley Shooter as3 tutorial

0 votes

it starts on this thread http://forum.shephertz.com/index.php/56/issues-with-snake-wars-tutorial?show=59#a59

i want to use the concept in the snake wars tutorial to limit the room for 2 players in the smiley shooter game

I tried some modifications in the AppWarpListener class, i'm following the concepts in here

http://appwarp.shephertz.com/game-development-center/Cocos2d-xna-multiplayer-tutorial/#how-does-the-integration-with-appwarp-work

 

first, the onConnectDone function: i put "WarpClient.getInstance().joinRoomInRange(1,1,true);" instead of joining a roomID

 public function onConnectDone(res:int):void
        {
           
            if (res == ResultCode.success) {
                WarpClient.getInstance().joinRoomInRange(1,1,true);
            }


            else if(res == ResultCode.api_not_found || res == ResultCode.auth_error){
                _owner.updateStatus("Verify your api key and secret key");
            }
            else if(res == ResultCode.connection_error){
                _owner.updateStatus("Network Error. Check your internet connectivity and retry.");
            }
            else{
                _owner.updateStatus("Unknown Error");
            }
        }

 

then, on the onJoinRoomDone:

        public function onJoinRoomDone(event:Room):void
        {
            
            if(event.result == ResultCode.success)
            {

                //point A

                roomID = event.roomId;
                WarpClient.getInstance().subscribeRoom(roomID);
                _owner.updateStatus("Started! Use up/down arrows and click to shoot.")


            } else if(event.result == ResultCode.resource_not_found)
            {

                //point B

                WarpClient.getInstance().createRoom("room", "admin", 2, null);
                trace(event.roomId);
                _owner.updateStatus("Room join failed. Verify your room id." );
            }
        }

through tracing, I know that when I start the swf, it reaches point B but it seems it fails to do the createRoom function properly since the trace(event.roomId) gives out null

and when I create a second swf the same thing happened, and the two players arent connected

when I tried "WarpClient.getInstance().joinRoomInRange(0,1,true);" instead of (1,1,true);, it actually works!

(from tracing, i found out that it only reaches point A in the onJoinRoomDone function)

I can run multiple SWFs at the same time and whenever there's already 2 players on the room, the new swf will create a new room with only 2 player limit.

But I can't differentiate which one is first/second player in a room since in the game I'm creating right now I need to differentiate it

asked Mar 2, 2014 in AppWarp by tdv (16 points)
retagged Mar 11, 2014 by shepAdmin

1 Answer

+1 vote
 
Best answer

through tracing, I know that when I start the swf, it reaches point B but it seems it fails to do the createRoom function properly since the trace(event.roomId) gives out null

So this is because room join failed so there is no room id (null). So tracing it will print null - thats expected. Why do you say createRoom is failing? Have you set a zoneRequestListener and seen whats the result of onCreateRoomDone event?
answered Mar 2, 2014 by dhruvc (1,099 points)
selected Mar 2, 2014 by tdv
i thought that once it's created there should be a event.roomId, guess I was mistaken about that

ok, so how do I join the room? I tried to implement the zoneRequestListener and add this on the onCreateRoomDone

public function onCreateRoomDone(event:Room):void
        {
            roomID = event.roomId;
            trace("roomID:" + roomID);
            WarpClient.getInstance().joinRoom(roomID);
        }

it still fails, and the trace didnt even appear, so onCreateRoomDone isn't even called?
joinRoomInRange attempts to join an existing room. If successful - the roomid in the event is valid else its invalid. It doesn't attempt to create a room. To create a dynamic room you need to call the createRoom API. The result is provided in onCreateRoomDone of the registered zonerequestlistener. You have probably not set the zone request listener and hence not getting a callback onCreateRoomDone. If its not called - doesn't mean its failed.. it means that the zone request listener has not been set.
you're right, forgot to set the zone request listener

thanks for all the help :)
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
...