Browse Source

gemfile for bundle install updated. Timeout rescue fixed

Paul Klumpp 8 years ago
parent
commit
3b88a21ccf
3 changed files with 12 additions and 9 deletions
  1. 1 0
      Gemfile
  2. 3 1
      PROTOCOL
  3. 8 8
      em_server.rb

+ 1 - 0
Gemfile

@@ -2,4 +2,5 @@ source 'https://rubygems.org'
 
 gem 'stomp'
 gem 'eventmachine'
+gem 'geoip'
 

+ 3 - 1
PROTOCOL

@@ -34,7 +34,9 @@ Central will gracefully close your connection.
 PING
 
 A command to test if connections and processing are still alive. Central will answer with "PONG [optional text]" to show
-it's still kicking around and working.
+it's still kicking around and working. We encourage all clients to send PING to central on a regular basis of about
+90 seconds. So your client will notice broken connections to begin reconnecting. We want a robust network. All clients
+need to find their connections by themselves.
 
 reply: PONG
 ------------------------------------------------------------------------------------------------------------------------

+ 8 - 8
em_server.rb

@@ -131,9 +131,8 @@ class GameServers
 
     udp_payload = udp_payload.pack("C*")
     #p udp_payload
-
-    Timeout::timeout(2) do
-      begin
+    begin
+      Timeout::timeout(2) do
         u2 = UDPSocket.new
         #put_log "#{iphost} #{ipport} #{udp_payload}"
         u2.send(udp_payload, 0, iphost, ipport)
@@ -158,12 +157,13 @@ class GameServers
         else
           return false
         end
+      end # of Timeout
 
-      rescue Exception => e
-        puts e.message
-      end # of begin
-    end # of Timeout
-
+    rescue Timeout::Error => e
+      put_log "Timeout. We go on."
+    rescue Exception => e
+      puts e.message
+  end # of begin
 
   end