sinatra-websocket gemを使用して異なるチャネルでメッセージを送信する方法はありますか?
基本的に、Pusher を sinatra-websocket に置き換えようとしています。プッシャーで私がやっていることは次のとおりです。
Pusher["my_channel_A"].trigger('some_event_type', my_message)
Pusher["my_channel_B"].trigger('another_event_type', my_message)
このsinatra-websocketスニペットの構文に相当するものは何ですか?
request.websocket do |ws|
ws.onopen do
ws.send("Hello World!")
settings.sockets << ws
end
ws.onmessage do |msg|
EM.next_tick { settings.sockets.each{|s| s.send(msg) } }
end
ws.onclose do
warn("websocket closed")
settings.sockets.delete(ws)
end
end