How to detect a network-disconnect

hi again =)

i’m back with another tricky problem^^
this time i have trouble with the network. i need to detect unexpected network-disconnects.
i already have a working network with a QueuedConnectionManager.
and resetConnectionAvailable returns true if i close one of my connections. but i need to know which one was closed so i can backup the player’s data and remove him from my world.
if possible i’d like to avoid to check every single player if his connection is still alive since i might end up with a lot of players.

any ideas or hints?

Is that what you need?

hm… not really. maybe… all i need is the connection which was lost.
when a palyer connects to the server i assign a playerID to this connection. i’m managing all data with this playerID like positions,items etc. so when a connection is lost i need to know which one or i cant store/backup all the players data. ( a regular logout is no problem but a lot of people use windows so noone can garantuee that they will log out properly :wink: )

I don’t think the connection still exists when it’s lost, does it?

When resetConnectionAvailable() returns true, you are expected to call getResetConnection() to retrieve the particular connection that was reset. The interface is similar to that of QueuedConnectionListener: you must pass a PointerToConnection to the function call, and then use the p() method to extract the actual connection.

David

hm… aahm. ok so far the theorie (even if i dont really get it)… my main problem is… which pointer do i need and to which connectrion does it have to point??
so far i have

#when i start the server...:
      self.tcpSocket = self.cManager.openTCPServerRendezvous(9099, 1000)
      self.connection = self.cListener.addConnection(self.tcpSocket)

#......lots of stuff between it .... and the following one is part of a task which runs with 10fps
    if self.cManager.resetConnectionAvailable() == True:
      print self.cManager.getResetConnection(self.connection)

… which gives me the error
TypeError: QueuedConnectionManager::get_reset_connection() argument 1 must be PointerTo_Connection, not int
since i dont know what exactly is requred…

Try:

connPointer = PointerToConnection()
self.cManager.getResetConnection(connPointer)
connection = connPointer.p()

Now the connection object matches the connection that has been shut down. If you have stored a mapping of connection -> client (for instance, in a dictionary) as each client connected, you can use this object to figure out which client is now gone.

David

thx again drwr … worked like a charm =)