FailedMessage Failed message that exceeded retry count.
inheritance
failed
numberreason
string8 declarations
FailedMessage Failed message that exceeded retry count.
failednumberreasonstringQueuedMessage Queued message that couldn't be sent immediately.
iddataanycreatednumberSocket class for WebSocket connection management with auto-reconnect and message queueing.
Cell<typeof SocketJson>wstype WebSocket | null
opentype boolean
statustype AsyncStatus
last_send_timetype number | null
last_receive_timetype number | null
last_connect_timetype number | null
heartbeat_timeouttype NodeJS.Timeout | null
reconnect_counttype number
reconnect_attempttype number
reconnect_timeouttype NodeJS.Timeout | null
current_reconnect_delaytype number
message_queuetype Array<QueuedMessage>
failed_messagestype SvelteMap<string, FailedMessage>
connectedtype boolean
can_sendtype boolean
has_queued_messagestype boolean
queued_message_counttype number
failed_message_counttype number
connection_durationtype number | null
connection_duration_roundedtype number | null
constructortype new (options: SocketOptions): Socket
optionsconnectConnects to the WebSocket server.
type (url?: string | null): void
urlThe WebSocket URL to connect to
string | nullnullvoiddisconnectDisconnects from the WebSocket server.
type (code?: number): void
codeThe close code to use (default: 1000 - normal closure)
numberDEFAULT_CLOSE_CODEvoidsendSends a message through the WebSocket.
type (data: object): boolean
dataThe data to send
objectbooleanTrue if the message was sent immediately, false if queued or failed
update_urlUpdates the connection URL and reconnects if currently connected.
type (url: string): void
urlThe new WebSocket URL
stringvoidsend_heartbeatSends a ping message for heartbeat purposes
type (): Promise<void>
Promise<void>retry_queued_messagesRetry sending all queued messages.
type (): void
voidclear_failed_messagesClear the failed messages list
type (): void
voidmaybe_reconnecttype (): void
voidcancel_reconnectCancel any pending reconnection attempt.
type (): void
voidadd_message_handlerAdd a message handler and return a function to remove it.
type (handler: SocketActionHandler): () => void
handlerThe message handler to add
() => voidA function that removes the handler when called
add_error_handlerAdd an error handler and return a function to remove it.
type (handler: SocketErrorHandler): () => void
handlerThe error handler to add
() => voidA function that removes the handler when called
SocketActionHandler SocketErrorHandler ZodObject<{ id: ZodDefault<$ZodBranded<ZodUUID, "Uuid">>; created: ZodDefault<$ZodBranded<ZodISODateTime, "Datetime">>; ... 6 more ...; auto_reconnect: ZodDefault<...>; }, $strict> { id?: string | undefined; created?: string | undefined; updated?: string | undefined; url?: string | null | undefined; url_input?: string | undefined; heartbeat_interval?: number | undefined; reconnect_delay?: number | undefined; reconnect_delay_max?: number | undefined; auto_reconnect?: boolean | undefined; } SocketOptions CellOptions<typeof SocketJson>