i'm trying to find the best way to handle ghosts rtmpt connections in a chat application. You know, when for some reasons users can't connect with rtmp, they are connected with rtmpt. Problem is if user gets disconnected during a session, most of time the server doesn't detect the disconnection, and shared objects users list is not updated. this can be a problem in application such as chat where connected users are displayed and/or functions such as private chat or whatever.
my idea was to save the ip address of each client in the shared object slot containing users infos. then everytime a user gets connected, checking if the IP address is already in the list, and if yes, not creating a new slot but updating the old one by changing only the new clientID, so the system don't create a duplicate user, and we can get a reference to the client ID for different purposes. of course this is not a very good option, as two differents clients could be connected using the same line, so having the same ip. so i'm wondering if there is a better option to handle these cases, which can become very problematic (rtmpt seems much less stable than rtmp, and it seems that people connected with rtmpt can get disconnected several times in shoirt periods, increasing again and again the list of ghost users...any help or advices regarding this matter would be much appreciated
You could add a unique ID per username and a timeout.
If the username is already in use (connected within the timeout period) and tries to connect again kick the current connection (based on unique ID) and allow the new connection.