Permalink
Browse files

Removed unused hash objects.

  • Loading branch information...
1 parent 9d69138 commit 81366a500d8fd6a86a00792758fee6aa2f519edd Dan Simpson committed Dec 15, 2009
Showing with 9 additions and 6 deletions.
  1. +9 −6 examples/tictactoe/tictactoe.rb
@@ -115,20 +115,16 @@ class TickTackToeServer < WebSocketServer
attr_accessor :game_id, :key, :status_key
def on_connect
- puts "C"
@status_key = $status.subscribe do |c|
send_user_count c
end
$status.increment
end
def on_disconnect
- puts "DC"
- if $games.key?(game_id)
- $games.delete(game_id)
- end
- $status.decrement
$status.unsubscribe @status_key
+ $status.decrement
+ delete_game!
end
def on_receive data
@@ -165,6 +161,12 @@ def on_receive data
end
end
+ def delete_game!
+ if $games.key?(game_id)
+ $games.delete(game_id)
+ end
+ end
+
def game
$games[game_id]
end
@@ -174,6 +176,7 @@ def turn!
end
def game_over!
+ delete_game!
send_command "game_over"
end

0 comments on commit 81366a5

Please sign in to comment.