Broadcast Messages
Basic Broadcasting
class NotificationChannel < Azu::Channel
PATH = "/notifications"
CONNECTIONS = [] of HTTP::WebSocket
def on_connect
CONNECTIONS << socket
end
def on_close(code, reason)
CONNECTIONS.delete(socket)
end
def self.broadcast(message : String)
CONNECTIONS.each do |ws|
ws.send(message)
end
end
endBroadcast to Others
Room-based Broadcasting
User-targeted Broadcasting
Broadcast with Filtering
Async Broadcasting
Broadcast from Background Jobs
Rate-limited Broadcasting
Batched Broadcasting
See Also
Last updated
Was this helpful?
