module Amber::WebSockets::ClientSockets

Overview

Manages the entire collection of ClientSockets. Manages periodic timers for socket connections (heartbeat). Also manages disconnected connection state for reconnection recovery.

Extended Modules

Defined in:

amber/websockets/client_sockets.cr

Constant Summary

Log = ::Log.for(self)

Instance Method Summary

Instance Method Detail

def add_client_socket(client_socket) #

[View source]
def buffer_message(connection_id : String, message : String) #

Buffers a message for a disconnected connection. If the buffer is full, the oldest message is dropped.


[View source]
def clear_disconnected_connections #

Clears all disconnected connection state. Useful for testing.


[View source]
def client_sockets #

[View source]
def get_subscribers_for_topic(topic) #

[View source]
def has_disconnected_connection?(connection_id : String) : Bool #

Returns whether a disconnected connection exists for the given connection_id.


[View source]
def max_message_buffer_size=(size : Int32) #

Configures the maximum message buffer size for disconnected connections.


[View source]
def reconnect_window=(duration : Time::Span) #

Configures the reconnection window duration.


[View source]
def recover_connection(connection_id : String) : DisconnectedConnection | Nil #

Attempts to recover a disconnected connection. Returns the buffered messages if the connection_id is found and still within the reconnection window, otherwise returns nil.


[View source]
def remove_client_socket(client_socket) #

[View source]
def track_disconnection(client_socket) #

Stores the state of a disconnected connection so it can be recovered when the client reconnects within the reconnection window.


[View source]