Forum Multiplayer AllowUserJoin and client response

Discussion and help relating to the Player.IO Multiplayer API

AllowUserJoin and client response

Postby wildbunny » September 17th, 2011, 5:34 pm

Hi guys,

I wanted to use AllowUserJoin to control version checking between client and server to make sure the client isn't out of date. Problem is when I return false in AllowUserJoin(), the client is disconnected, but on the client neither of the callbacks in createJoinRoom are called, so I can't display a message informing the client that they have an out of date version.

How do you handle this?

Cheers, Paul.
wildbunny
 
Posts: 217
Joined: March 9th, 2011, 10:35 am

Re: AllowUserJoin and client response

Postby garysimmons » September 19th, 2011, 8:40 pm

Hi Paul,

What I do in my game is have a deferred join game list. I need this for many other reasons more specific for my game. But essentially..in UserJoin() I do nothing more than add the player to a ConnectionQueue (just a list). Then in my main game loop I check the queue to see if there are any newly joined players that have joined the room and are awaiting to be connected to their game world objects. I then process the any players in the queue and add add them to the main players list and remove them from the connection queue.

Now...that means that it is in this connection queue processor function that you can test to see whether the player should TRULY join your game and if not...you can send a "Client Out of Date" message to the client and then disconnect them from the server.

Hope that helps
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin and client response

Postby Oliver » September 20th, 2011, 2:37 pm

The way it works is that connection success should fire, and then you should be immediately disconnected if allowuserjoin returns false. This allows you to send messages to the client in the AllowUserJoin method that describe why the user was disconnected, and read them on the clientside before the user is disconnected.

Are you not seeing this behavior?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1136
Joined: January 12th, 2010, 8:29 am

Re: AllowUserJoin and client response

Postby wildbunny » September 24th, 2011, 6:46 pm

Sorry Oliver, I must have made a mistake - this is working exactly as it should :)
wildbunny
 
Posts: 217
Joined: March 9th, 2011, 10:35 am

Re: AllowUserJoin and client response

Postby vale » December 23rd, 2011, 4:33 pm

Oliver wrote:The way it works is that connection success should fire, and then you should be immediately disconnected if allowuserjoin returns false. This allows you to send messages to the client in the AllowUserJoin method that describe why the user was disconnected, and read them on the clientside before the user is disconnected.

Are you not seeing this behavior?

Hello Oliver,

Unfortunately this behavior is not respected all the time. I'm waiting for the "groupdisallowedjoin" message type, which not fires all the time. I think sometimes the user get disconnected before the user receive this message. I really need to show a message to my users when the room is full, but because "groupdisallowedjoin" message is not 100% trusted, what method can I use?

Thank you
vale
Paid Member
 
Posts: 10
Joined: August 3rd, 2010, 3:16 pm

Re: AllowUserJoin and client response

Postby Oliver » January 2nd, 2012, 10:45 am

Hello Vale,

Please start new threads, as it makes it easier to grasp the context of the error.

I need some additional details:
- Which environment are you using? Flash, unity?
- When you say "not respected all the time", what does that mean? If you just rerun the same code a bunch of times, will it fail some % of it, or ?
- Can you share the code so we can try to reproduce it ourselves?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1136
Joined: January 12th, 2010, 8:29 am

Re: AllowUserJoin and client response

Postby vale » January 4th, 2012, 6:48 pm

Hello Oliver
I develop using Flash cs5. The playerio SDK version is 1.8;
Code: Select all
var GlobalClient:Client;
var GlobalConnection:Connection;
PlayerIO.connect(stage/*Referance to stage*/, "xxxxxxxxxxxxx"/*Game id */, "public", "xxxx"/*Username*/, ""/*User auth*/, handleConnect, handleError);

function handleConnect(client:Client):void
{
   GlobalClient = client;
   client.multiplayer.developmentServer = "localhost:8184";
   GlobalClient.multiplayer.createJoinRoom(null, "MyCode", true, {maxplayers:2, playmode:'direct'}, {}, handleJoin, handleError);

}
function handleJoin(connection:Connection):void {
   GlobalConnection = connection;
   GlobalConnection.addMessageHandler("*", handleMessages);
}
function handleMessages(m:Message) {
   trace("Recived the message", m);
}

On the server side I simply have the allowUserJoin which return false;

By rerunning this swf, sometimes I receive "groupdisallowjoin", sometimes I didn't.

I don't think that this is because of my v1.8 SDK version.

Thank you
vale
Paid Member
 
Posts: 10
Joined: August 3rd, 2010, 3:16 pm

Re: AllowUserJoin and client response

Postby Oliver » January 5th, 2012, 1:55 pm

hey vale, can you post the serverside code also?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1136
Joined: January 12th, 2010, 8:29 am


Return to Multiplayer