views:

57

answers:

2

I got a four player pong game and when one player disconnects (because of any reason, incomming call, bored, catch a bus) the other players can continue playing. However I want that person to be able to reconnect after his call is finished, does anyone have an idea how I can pull that off?

When two players were evolved I would just reinvite that person but how must I do it in this situation?

Edit: I forgot to mention that I am using the Game Center API. So I am using the match object to send data to the players, but after a player gets disconnected will the match still work and if not is there a way to rejoin the match?

+1  A: 

1) create a key that defines this user as part of this game (maybe a UUID shared with all players of this game along with a user x of y component?)

2) search for the methodology to relaunch your app after it's been interrupted

3) relaunch, send the unique key to the server, rejoin the game

KevinDTimm
First of all Kevin, thanks for your reply. Second, it was regarding Game Center, I am using the Match object I can store this object but will I am not sure if it will be enough to rejoin the match. I will try now.
Mark
A: 

Maybe your game has usernames? so if a player disconnects then comes around again when he connects to server check if that username is in any previous games/rooms? note: this means the usernames should be unique.

Otherwise do some kind of a userId system where each new user to register to your game is given a number incremented from the previous user to register save that number clientsided like cookies from browsers and send the number to server when disconnected player is joining again.

Both methods can easily be exploited by reverse engineering the saved file or picking out a username that disconnected on a different phone for example.

Best method would be to use some kind of a username/password system which makes all usernames unique.

If a user connects a 2nd/3rd time then the server should give out a message of some sort saying the person is currently logged in?

If that person gets interrupted then either send a disconnect packet or if you can't the server can take care of this. Either the connection will be lost with server so the user's state goes disconnected. Or somehow the connection is still alive? maybe UDP socket? the server will attempt to send a ping-pong type of packet if no response then obviously user is disconnected from that app so set state to disconnected etc..

SSpoke
what to do then when a user logs in again (2nd, 3rd, ...) time?
KevinDTimm
what did i say wrong?
SSpoke