I need to create a game room dynamically for only 2 users. How can I create a different room dynamically if the room created earlier has 2 users in it already.
What I need exactly is, if there are 0 users currently connected and then (user1) connects, he gets to create a game room. The next (user2) connecting gets to join the room already created by the (user1), instead of creating a game room of his own. The next user connecting (user3) then creates a game room of his own as no room is available for him to join. Later (user4) connects and he gets to join the room created by (user3) instead of creating a room of his own. This goes on and on for every ODD user being my first player and the EVEN being my second player.
Hi,
I think I've posted this example somewhere else but I can't find it right now so I'll post it here again.
It's a bit of server side code that handles a request called "joinme" from the client. The server then searches for a Room with a free spot and if it is found it will join the player. Otherwise it will create a new Room with makeNewRoom(...) method and join the player there.
What do I need to do to display my user names / player names in two different text fields one to the left and 1 to the right for a game room for only two players?
Do I need to program it on the server side or client side and do I need to use user variables.
I just need to display the player names.
Once both players are connected you can obtain their names from the Room's user list.
When you are waiting for the 2nd player to join the Room you can use a temporary text such as "Waiting player..."
handleClientRequest(String cmd, User user, ISFSObject params) //needs 3 parameters when it extends SFSExtension and only 2 when it extends
BaseClientRequestHandler(User user, ISFSObject params)
When you use the addRequestHandler(...) method you are already saying which command name should trigger which Request handler, therefore you don't get the command name in your request handler anymore and you don't need any if statement.