Paul Klumpp 11 سال پیش
والد
کامیت
a63bcaeb53
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 6 1
      em_server.rb

+ 6 - 1
em_server.rb

@@ -368,8 +368,11 @@ module InterconnectionPointProtocolHandler
 
         if $user_roles.any? {|k| k.include? username}
           @username = username
-
           @@connected_clients.push(self)
+          @ping_timer = EventMachine.add_periodic_timer 90, proc { write_user("PING alive?") }
+
+          # starting a pinger
+          write_user("HELLO Hi user '#{@username}'! How are you? I'm '#{$version}'")
 
           put_log("SYS '#{@username}' connected. Online now: #{ousers.join(", ")}")
 
@@ -394,6 +397,8 @@ module InterconnectionPointProtocolHandler
 	def unbind # a connection goes bye bye
 		if @username
 			@@connected_clients.delete(self)
+      EventMachine.cancel_timer(@ping_timer)
+
 			put_log "SYS '#{@username}' disconnected."
 		end
     put_log "SYS Online users now: #{ousers.join(", ")}"