abstract struct Amber::WebSockets::ClientSocket
- Amber::WebSockets::ClientSocket
- Struct
- Value
- Object
Overview
ClientSocket
struct maps a user to an HTTP::WebSocket. For every websocket connection
there will be an associated ClientSocket. Authentication and authorization happen within the ClientSocket
. ClientSocket
will subscribe to Channel
s,
where incoming and outgoing messages are routed through.
Example:
struct UserSocket < Amber::Websockets::ClientSocket
channel "user_channel:*", UserChannel
channel "room_channel:*", RoomChannel
def on_connect
return some_auth_method!
end
end
Defined in:
amber/websockets/client_socket.crConstant Summary
-
BEAT_INTERVAL =
30.seconds
-
Log =
::Log.for(self)
-
MAX_SOCKET_IDLE_TIME =
100.seconds
Constructors
Class Method Summary
-
.broadcast(event : String, topic : String, subject : String, payload : Hash)
Broadcast a message to all subscribers of the topic
-
.channel(channel_path, ch)
Add a channel for this socket to listen, publish to
- .channels
- .get_topic_channel(topic_path)
Instance Method Summary
-
#on_connect : Bool
Authentication and authorization can happen here
-
#on_disconnect
On socket disconnect functionality
- #socket : HTTP::WebSocket
Constructor Detail
Class Method Detail
Broadcast a message to all subscribers of the topic
UserSocket.broadcast("message", "chats_room:1", "msg:new", {"message" => "test"})