Skip to content

Instantly share code, notes, and snippets.

@ianbishop
Created March 23, 2011 23:41
Show Gist options
  • Save ianbishop/884269 to your computer and use it in GitHub Desktop.
Save ianbishop/884269 to your computer and use it in GitHub Desktop.
A new module for the simple message passing system
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