Skip to content

Instantly share code, notes, and snippets.

@imanel
Created February 12, 2013 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imanel/a00d6b65561ebba43b9a to your computer and use it in GitHub Desktop.
Save imanel/a00d6b65561ebba43b9a to your computer and use it in GitHub Desktop.
class Socket < Rack::WebSocket::Application
def self.connections
@connections ||= []
end
def self.send_to_all(message)
@connections.each {|connection| connection.send_data(message)
end
def on_open(env)
self.class.connections << self
end
def on_close(env)
self.class.connection.delete(self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment