Forum Multiplayer AllowUserJoin bug?

Discussion and help relating to the Player.IO Multiplayer API

AllowUserJoin bug?

Postby whitershores » July 17th, 2011, 6:19 pm

This is either a bug or just extremely counter intiutive.

on client i call this:
Code: Select all
multiplayer.joinRoom() // player tries to join a room
// which has this callback function upon success
handleJoin(c:Connection)


on server
Code: Select all
public override bool AllowUserJoin(Player player)
{
if (PlayerCount +1 > 2) //can only have a maximum of 2 players, after that they are denied to join
{
  Console.WriteLine("AllowUserJoin returned false ->room is full");
  return false;
}
return true;
}


I try to join the room with 3 clients, this is the trace I get from the dev server:
Code: Select all
=====[  Room Started:   ]===========
>User Guest-3509 (1): Joined game
>User Guest-877 (2): Joined game
>User Guest-674 (3): Joined game
AllowUserJoin returned false ->room is full
>User Guest-674 (3): Left game


- In my understanding I should not get "User Guest-674 (3): Joined game" as he didn't join, but was denied?
This also results in the bigger problem of handleJoin being called? So the client thinks he has joined the room, and produces dialogs etc, where as in the server he was actually denied..
Last edited by whitershores on July 17th, 2011, 6:24 pm, edited 3 times in total.
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby Toby » July 17th, 2011, 6:22 pm

Just to clarify, does the userJoined function actually execute (I noticed you haven't got any traces from it)? The dev server could just be printing out those lines regardless.
User avatar
Toby
 
Posts: 85
Joined: January 14th, 2010, 4:01 pm

Re: AllowUserJoin bug?

Postby whitershores » July 17th, 2011, 6:29 pm

Not sure, I am not overriding them. But my actual problem is not the dev server, but that this function

multiplayer.joinRoom()
-has a callback function after success, which Does get executed

Code: Select all
function handleJoinedRoomSuccess(connection:Connection):void
{
   trace("Sucessfully  joined room!");
}


- which would obviously mean that it got a positive response from the server, that the user has joined... where as he was not
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby whitershores » July 17th, 2011, 7:33 pm

This really does seem like a bug, even the TicTacToe game is suffering from it. Just add the

Code: Select all
public override bool AllowUserJoin(Player player)
{
if (PlayerCount +1 > 2) //can only have a maximum of 2 players, after that they are denied to join
{
  Console.WriteLine("AllowUserJoin returned false ->room is full");
  return false;
}
return true;
}


to the server side, and you will still be ableto join the game beyond the 2 player limit
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby garysimmons » July 17th, 2011, 10:34 pm

Ok after reading your post I tested it on my server two by ALWAYS returning false in AllowUserJoin and the server definitely reports that I Join the game and then Leave the game :(
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin bug?

Postby whitershores » July 17th, 2011, 11:08 pm

the server reporting that you join/leave after each other isnt really a big problem

the BIG problem is that the
multiplayer.joinRoom()'s success handler returns with a Connection object, even with connected = true, which is telling the client "hey you joined the room alright" where as the server thinks you havent joined at all.
So then your logic on the client would try to put the player into a game or show lobby etc, where as he isnt even in the room...
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby garysimmons » July 18th, 2011, 2:09 am

When the success handler is called you are passed a connection object. Is this valid and have you tried testing the properties of this object. In the mean time you might be able to work around this by testing for example, whether the connection object is null or if the connection.connected property is set to true. Perhaps this is by design? Perhaps that error callback is only to be triggered in the case of an error in the connection system. In the case of being rejected from a room....its not really an error as in fact the system is working as expected its just a feature :). Just thinking aloud here I am sure the tech guys here at playerio will sort this out pretty quickly if this is a bug. In the meantime....I am away from my dev machine for a few days so can't test the connection object properties myself but would be interested in what they turn up for you.
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin bug?

Postby whitershores » July 18th, 2011, 3:11 am

that was my first thought as well, but as I said, the connection.connected, returns true, so it totally looks like you are all set, and joined the room

in the official documentation/examples, (from the FridgeMagnets.as) it says

handleJoin, //Function executed on successful joining of the room

- Ie, the handler should only be called If, we joined the room successfully, and not just we have attempted to join, or there wasnt some other error, but after we are in the room for good
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby whitershores » July 19th, 2011, 1:33 am

any new on this?

So just to sum it up, players who are denied to join a room by AllowUserJoin, still get

Client.multiplayer.joinRoom()'s success handler function called, with a valid Connection object with connected = true;
So there is no easy way to tell that the user has actually failed to join.

I tested this on both development and live servers and they both seem to be suffering from this problem
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby Toby » July 19th, 2011, 6:25 pm

That's odd.

The client fires the disconnect even, though, I assume? Which I suppose works.

I get your point though, it would be much nicer if it just failed the connection in the callback.
User avatar
Toby
 
Posts: 85
Joined: January 14th, 2010, 4:01 pm

Re: AllowUserJoin bug?

Postby whitershores » July 19th, 2011, 6:52 pm

Yes, the disconnect is fired, I even tried to call Disconnect() in the AllowUserJoin() method, on the Server side, to eject the player sooner, but to no avail, the Client executes the Success handler regardless of that.

I hope someone from PlayerIO is dealing with this...
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby Henrik » July 20th, 2011, 3:30 am

That sounds weird, we'll look into it.
User avatar
Henrik
.IO
 
Posts: 575
Joined: January 4th, 2010, 1:53 pm

Re: AllowUserJoin bug?

Postby garysimmons » July 20th, 2011, 7:03 pm

In the meantime I suppose you could hack around this by writing something like "NOTCONNECTED" to the player object in AllowUserJoin() and then test for that property on the client side when the callback fires.
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin bug?

Postby Dg74 » July 20th, 2011, 8:07 pm

Good! I’m glad to see I’m not the only one with this problem. When working on adding the option of private password protected rooms to my game I was very perplexed when the AllowUserJoin returned false to a user their handleJoin() function still ran and the server tells me they joined before immediately leaving.

Also I get a warning when I try to write a line to the console inside the AllowUserJoin function
Saying “Unreachable code detected” and it does not write anything. I’m not sure if that is related. It looks like you where able to do it.

whitershores wrote:on server
Code: Select all
public override bool AllowUserJoin(Player player)
{
if (PlayerCount +1 > 2) //can only have a maximum of 2 players, after that they are denied to join
{
  Console.WriteLine("AllowUserJoin returned false ->room is full");
  return false;
}
return true;
}



I hope this all gets sorted out soon.
Dg74
 
Posts: 5
Joined: May 19th, 2011, 9:33 pm

Re: AllowUserJoin bug?

Postby whitershores » July 20th, 2011, 8:51 pm

Yep, I run into this code while buildig a password protected(and player number limited) system as well!

It would be ideal if this issue got resolved quickly
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby whitershores » July 28th, 2011, 1:45 pm

Any progress on this?
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby garysimmons » July 28th, 2011, 3:16 pm

Yep this is quite an important fix for me too
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin bug?

Postby Benjaminsen » July 31st, 2011, 9:30 pm

Quick update:

No fixes, but an explanation of why things work as they do. The success callback in the AS3 client has nothing to do with successfully joining a room. It fires when you have managed to successfully establish a TCP/IP connection to the servers.

The reason it's implemented as such is that we wanted to allow you as a developer to tell the user why they where not allowed to connect to the server. Thus in AllowUserJoin you can actually use player.Send(..) to send out messages to the user before they are getting disconnected.

I personally use this in Everybody Edits to inform users that they are banned, the room is full etc before disallowing the join.

We do realize that this does however creates some confusing and are looking into ways to restructure the API to allow for the same capability while triggering the errorHander in the connect method.
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
User avatar
Benjaminsen
.IO
 
Posts: 808
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: AllowUserJoin bug?

Postby garysimmons » July 31st, 2011, 11:23 pm

Thanks for the response Chris. So as it stands at the moment, how does the true / false boolean response from the AllowUserJoin function affect the system?

cheers
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin bug?

Postby Toby » August 1st, 2011, 11:47 am

garysimmons wrote:How does the true / false boolean response from the AllowUserJoin function affect the system?


It determines whether or not the UserJoined method is called and whether or not the player is added to the Players IEnumerable.
User avatar
Toby
 
Posts: 85
Joined: January 14th, 2010, 4:01 pm

Re: AllowUserJoin bug?

Postby garysimmons » August 1st, 2011, 7:04 pm

ahh that's good. So the server bit all works as expected. It's just the client side that is a bit weird :)

thx
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: AllowUserJoin bug?

Postby whitershores » August 14th, 2011, 11:30 pm

Just to clarify, as the new version of the Server is out, was this issue fixed? ( cant test atm)
whitershores
Paid Member
 
Posts: 38
Joined: June 21st, 2011, 4:19 pm

Re: AllowUserJoin bug?

Postby wbsaputra » January 18th, 2012, 9:06 pm

i try to send message to client at allow user join function to display a message, but it seems doesn't work.
I need to kick user which trying to join twice to room with same user id.

public override void UserJoined(Player ply)
{
bool res = true;
int usrCount = 0;
foreach (Player p in Players)
{
if (p.ConnectUserId == ply.ConnectUserId)
{
usrCount++;
}
}

if (usrCount > 1)
{
ply.Send("kick");
res = false;
}

return res;
}
Any clue why this code not working
wbsaputra
Paid Member
 
Posts: 116
Joined: June 29th, 2010, 4:38 pm


Return to Multiplayer