abstract class Launch::WebSockets::Channel
- Launch::WebSockets::Channel
- Reference
- Object
Overview
Sockets subscribe to Channels, where the communication log is handled. The channel provides functionality
to handle socket join #handle_joined
and socket messages handle_message(msg)
.
Example:
class ChatChannel < Launch::Websockets::Channel
def handle_joined(client_socket)
# functionality when the user joins the channel, optional
end
def handle_leave(client_socket)
# functionality when the user leaves the channel, optional
end
# functionality when a socket sends a message to a channel, required
def handle_message(msg)
rebroadcast!(msg)
end
end
Defined in:
launch/websockets/channel.crConstructors
Instance Method Summary
-
#handle_joined(client_socket, message)
Authorization can happen here
- #handle_leave(client_socket)
- #handle_message(client_socket, msg)
-
#on_message(client_socket_id, message)
Called from proc when message is returned from the pubsub service
Constructor Detail
Instance Method Detail
def on_message(client_socket_id, message)
#
Called from proc when message is returned from the pubsub service