abstract struct Lattice::ClientSocket
- Lattice::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.
struct UserSocket < Lattice::ClientSocket
channel "user_channel:*", UserChannel
channel "room_channel:*", RoomChannel
def on_connect
return some_auth_method!
end
end
Defined in:
lattice/client_socket.crConstant Summary
-
BEAT_INTERVAL =
30.seconds
-
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, channel)
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
- #on_error : Proc(String, Nil) | Nil
- #on_error(&block)
- #on_error=(on_error : Proc(String, Nil) | Nil)
- #on_uncaptured_event(*args, **options)
- #on_uncaptured_event(*args, **options, &)
- #socket : HTTP::WebSocket
Constructor Detail
Class Method Detail
def self.broadcast(event : String, topic : String, subject : String, payload : Hash)
#
Broadcast a message to all subscribers of the topic
UserSocket.broadcast("message", "chats_room:1", "msg:new", {"message" => "test"})