Skip to main content
Version: 3.x.x

Socket


import { Socket } from "@hyper-fetch/sockets"

Description

Defined in socket/socket.ts:30

Parameters

NameDetails

options

Required

SocketAdapterOptionsType<Adapter>

Properties

adapter

Description

Defined in socket/socket.ts:52

Type

Adapter

appManager

Description

Defined in socket/socket.ts:54

Type

AppManager

auth

Description

Defined in socket/socket.ts:37

Type

string | QueryParamsType

autoConnect

Description

Defined in socket/socket.ts:40

Type

boolean

debug

Description

Defined in socket/socket.ts:39

Type

boolean

emitter

Description

Defined in socket/socket.ts:31

Type

EventEmitter

events

Description

Defined in socket/socket.ts:32

Type

{ emitClose: () => void; emitConnecting: () => void; emitEmitterEvent: <EmitterType>(emitter: EmitterType) => void; emitError: <ResponseType>(event: ResponseType) => void; emitListenerEvent: <ResponseType>(name: string, data: ResponseType, event: MessageEvent<ResponseType>) => void; emitListenerRemoveEvent: (name: string) => void; emitOpen: () => void; emitReconnecting: (attempts: number) => void; emitReconnectingStop: (attempts: number) => void; onClose: (callback: () => void) => VoidFunction; onConnecting: (callback: () => void) => VoidFunction; onEmitterEvent: <EmitterType>(callback: (emitter: EmitterType) => void) => VoidFunction; onEmitterEventByName: <EmitterType>(emitter: EmitterType, callback: (emitter: EmitterType) => void) => VoidFunction; onError: (callback: <ResponseType>(event: ResponseType) => void) => VoidFunction; onListenerEvent: <ResponseType>(callback: (data: ResponseType, event: MessageEvent<ResponseType>) => void) => VoidFunction; onListenerEventByName: <ListenerType>(listener: ListenerType, callback: (data: ExtractListenerResponseType<ListenerType>, event: MessageEvent<ExtractListenerResponseType<ListenerType>>) => void) => VoidFunction; onListenerRemove: (callback: (name: string) => void) => VoidFunction; onListenerRemoveByName: <ListenerType>(listener: ListenerType, callback: () => void) => VoidFunction; onOpen: (callback: () => void) => VoidFunction; onReconnecting: (callback: (attempts: number) => void) => VoidFunction; onReconnectingStop: (callback: (attempts: number) => void) => VoidFunction }

logger

Description

Defined in socket/socket.ts:58

Type

LoggerType

loggerManager

Description

Defined in socket/socket.ts:53

Type

LoggerManager

options

Description

Defined in socket/socket.ts:67

Type

SocketAdapterOptionsType<Adapter>

queryParams

Description

Defined in socket/socket.ts:38

Type

string | QueryParamsType

queryParamsConfig

Description

Defined in socket/socket.ts:55

Type

QueryStringifyOptionsType

queryParamsStringify

Description

Method to stringify query params from objects.

Defined in socket/socket.ts:63

Type

StringifyCallbackType

reconnect

Description

Defined in socket/socket.ts:35

Type

number

reconnectTime

Description

Defined in socket/socket.ts:36

Type

number

url

Description

Defined in socket/socket.ts:34

Type

string

__onCloseCallbacks

Description

Defined in socket/socket.ts:44

Type

CloseCallbackType<Socket<Adapter>, any>[]

__onErrorCallbacks

Description

Defined in socket/socket.ts:49

Type

ErrorCallbackType<Socket<Adapter>, any>[]

__onMessageCallbacks

Description

Defined in socket/socket.ts:47

Type

MessageCallbackType<Socket<Adapter>, any>[]

__onOpenCallbacks

Description

Defined in socket/socket.ts:43

Type

OpenCallbackType<Socket<Adapter>, any>[]

__onReconnectCallbacks

Description

Defined in socket/socket.ts:45

Type

ReconnectCallbackType<Socket<Adapter>>[]

__onReconnectStopCallbacks

Description

Defined in socket/socket.ts:46

Type

ReconnectStopCallbackType<Socket<Adapter>>[]

__onSendCallbacks

Description

Defined in socket/socket.ts:48

Type

SendCallbackType<EmitterInstance>[]

Methods

createEmitter()

Preview

createEmitter<Payload, Response>(options)

Description

Create event emitter

Defined in socket/socket.ts:247

Parameters

NameDetails

options

Required

EmitterOptionsType<Adapter>

Return

Emitter<Payload, Response, Adapter, void>

createListener()

Preview

createListener<Response>(options)

Description

Create event listener

Defined in socket/socket.ts:238

Parameters

NameDetails

options

Required

ListenerOptionsType<Adapter>

Return

Listener<Response, Adapter>

onClose()

Preview

onClose<Event>(callback)

Description

Triggered when connection is closed

Defined in socket/socket.ts:158

Parameters

NameDetails

callback

Required

CloseCallbackType<Socket<Adapter>, Event>

Return

Socket<Adapter>

onError()

Preview

onError<Event>(callback)

Description

Triggered when we receive error

Defined in socket/socket.ts:208

Parameters

NameDetails

callback

Required

ErrorCallbackType<Socket<Adapter>, Event>

Return

Socket<Adapter>

onMessage()

Preview

onMessage<Event>(callback)

Description

Triggered when any message is received

Defined in socket/socket.ts:188

Parameters

NameDetails

callback

Required

MessageCallbackType<Socket<Adapter>, Event>

Return

Socket<Adapter>

onOpen()

Preview

onOpen<Event>(callback)

Description

Triggered when connection is opened

Defined in socket/socket.ts:149

Parameters

NameDetails

callback

Required

OpenCallbackType<Socket<Adapter>, Event>

Return

Socket<Adapter>

onReconnect()

Preview

onReconnect(callback)

Description

Triggered when connection is getting reconnected

Defined in socket/socket.ts:168

Parameters

NameDetails

callback

Required

ReconnectCallbackType<Socket<Adapter>>

Return

Socket<Adapter>

onReconnectStop()

Preview

onReconnectStop(callback)

Description

Triggered when connection attempts are stopped

Defined in socket/socket.ts:178

Parameters

NameDetails

callback

Required

ReconnectStopCallbackType<Socket<Adapter>>

Return

Socket<Adapter>

onSend()

Preview

onSend<EmitterType>(callback)

Description

Triggered when any event is emitted

Defined in socket/socket.ts:198

Parameters

NameDetails

callback

Required

SendCallbackType<EmitterType>

Return

Socket<Adapter>

setAuth()

Preview

setAuth(auth)

Description

Set the new auth data to the socket

Defined in socket/socket.ts:125

Parameters

NameDetails

auth

Required

string | QueryParamsType

Return

this

setDebug()

Preview

setDebug(debug)

Description

This method enables the logger usage and display the logs in console

Defined in socket/socket.ts:101

Parameters

NameDetails

debug

Required

boolean

Return

this

setLogger()

Preview

setLogger(callback)

Description

Set the new logger instance to the socket

Defined in socket/socket.ts:117

Parameters

NameDetails

callback

Required

(socket: Socket<Adapter>) => LoggerManager

Return

this

setLoggerSeverity()

Preview

setLoggerSeverity(severity)

Description

Set the logger severity of the messages displayed to the console

Defined in socket/socket.ts:109

Parameters

NameDetails

severity

Required

SeverityType

Return

this

setQuery()

Preview

setQuery(queryParams)

Description

Set the new query data to the socket

Defined in socket/socket.ts:134

Parameters

NameDetails

queryParams

Required

string | QueryParamsType

Return

this

__modifyResponse()

Preview

__modifyResponse(response)

Description

Defined in socket/socket.ts:223

Parameters

NameDetails

response

Required

MessageEvent<any>

Return

MessageEvent<any>

__modifySend()

Preview

__modifySend(emitter)

Description


Interceptors


Defined in socket/socket.ts:219

Parameters

NameDetails

emitter

Required

EmitterInstance

Return

Emitter<any, any, any>