Paul Klumpp 11 anni fa
parent
commit
f2f0eb3d4e
1 ha cambiato i file con 12 aggiunte e 3 eliminazioni
  1. 12 3
      em_server.rb

+ 12 - 3
em_server.rb

@@ -345,10 +345,17 @@ module InterconnectionPointProtocolHandler
 
     if line
 
+
       if entered_username? # oh, it's a known user
-        # it's alive!
-        inputter = inputting(line)
 
+        # it's alive! kill ping timer, set a new one:
+        if @ping_timer
+          EventMachine.cancel_timer(@ping_timer)
+        end
+        @ping_timer = EventMachine.add_periodic_timer 90, proc { write_user("PING alive?") }
+
+        # work on input
+        inputter = inputting(line)
         if inputter == "bye"
           close_connection
         end
@@ -397,7 +404,9 @@ module InterconnectionPointProtocolHandler
 	def unbind # a connection goes bye bye
 		if @username
 			@@connected_clients.delete(self)
-      EventMachine.cancel_timer(@ping_timer)
+      if @ping_timer
+        EventMachine.cancel_timer(@ping_timer)
+      end
 
 			put_log "SYS '#{@username}' disconnected."
 		end