{"action":"created","issue":{"url":"https://api.github.com/repos/imanel/websocket-rack/issues/16","labels_url":"https://api.github.com/repos/imanel/websocket-rack/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/imanel/websocket-rack/issues/16/comments","events_url":"https://api.github.com/repos/imanel/websocket-rack/issues/16/events","html_url":"https://github.com/imanel/websocket-rack/issues/16","id":59888396,"number":16,"title":"Broadcasting?","user":{"login":"stephanemombuleau","id":3513099,"avatar_url":"https://avatars.githubusercontent.com/u/3513099?v=3","gravatar_id":"","url":"https://api.github.com/users/stephanemombuleau","html_url":"https://github.com/stephanemombuleau","followers_url":"https://api.github.com/users/stephanemombuleau/followers","following_url":"https://api.github.com/users/stephanemombuleau/following{/other_user}","gists_url":"https://api.github.com/users/stephanemombuleau/gists{/gist_id}","starred_url":"https://api.github.com/users/stephanemombuleau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephanemombuleau/subscriptions","organizations_url":"https://api.github.com/users/stephanemombuleau/orgs","repos_url":"https://api.github.com/users/stephanemombuleau/repos","events_url":"https://api.github.com/users/stephanemombuleau/events{/privacy}","received_events_url":"https://api.github.com/users/stephanemombuleau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-05T00:57:43Z","updated_at":"2015-03-07T08:27:10Z","closed_at":null,"body":"Hi!\r\n\r\nThis gem doesn't seem to handle broadcasting to all clients. Am I right?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/imanel/websocket-rack/issues/comments/77679347","html_url":"https://github.com/imanel/websocket-rack/issues/16#issuecomment-77679347","issue_url":"https://api.github.com/repos/imanel/websocket-rack/issues/16","id":77679347,"user":{"login":"imanel","id":36869,"avatar_url":"https://avatars.githubusercontent.com/u/36869?v=3","gravatar_id":"","url":"https://api.github.com/users/imanel","html_url":"https://github.com/imanel","followers_url":"https://api.github.com/users/imanel/followers","following_url":"https://api.github.com/users/imanel/following{/other_user}","gists_url":"https://api.github.com/users/imanel/gists{/gist_id}","starred_url":"https://api.github.com/users/imanel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imanel/subscriptions","organizations_url":"https://api.github.com/users/imanel/orgs","repos_url":"https://api.github.com/users/imanel/repos","events_url":"https://api.github.com/users/imanel/events{/privacy}","received_events_url":"https://api.github.com/users/imanel/received_events","type":"User","site_admin":false},"created_at":"2015-03-07T08:27:10Z","updated_at":"2015-03-07T08:27:10Z","body":"There is no 'broadcast' method by default, but it's easy to implement it by yourself depending on requirements:\r\n\r\n```\r\nclass MyApp < Rack::WebSocket::Application\r\n  def self.clients\r\n    @clients ||= Set.new\r\n  end\r\n\r\n  def on_open(env)\r\n    self.class.clients.add(self)\r\n  end\r\n\r\n  def on_message(env, msg)\r\n    self.class.clients.each do |client|\r\n      client.send_data(msg) unless client == self\r\n    end\r\n  end\r\n\r\n  def on_close(env)\r\n    self.class.clients.delete(self)\r\n  end\r\nend\r\n```\r\n\r\nThe reason for not implementing it is that each application have different requirements: some need sending to every client, some exclude themselves (see example above) and some sends only to specific groups."}}