Created
March 23, 2011 23:41
-
-
Save ianbishop/884269 to your computer and use it in GitHub Desktop.
A new module for the simple message passing system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GameMultiplayer | |
include Subscriber | |
def initialize(repeater) | |
@repeater = repeater | |
@repeater.subscribe(self) | |
end | |
def accept(message) | |
case message[:command] | |
when "accept move" | |
send_move(message[:color], message[:x], message[:y]) | |
else | |
end | |
end | |
# sends the move to the server | |
def send_move(color, x, y) | |
puts "#{self.class} sends to server: move(#{color},#{x},#{y})" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment