Last active
November 20, 2016 14:27
-
-
Save marcgg/47233a6ca0fe8cc126685bc2a635460c to your computer and use it in GitHub Desktop.
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 Note | |
def self.add(player_id, x, y) | |
key = "note_#{SecureRandom.hex}" | |
REDIS.set(key, { | |
x: x, y: y, player_id: player_id | |
}.to_json) | |
REDIS.expire(key, 5) | |
broadcast_note(player_id, x, y) | |
REDIS.incr("count_notes") | |
end | |
private | |
def self.broadcast_note(player_id, x, y) | |
puts "Broadcasting note by #{player_id}" | |
ActionCable.server.broadcast( | |
"game", { | |
type: "note", | |
player_id: player_id, | |
x: x, y: y | |
} | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment