Skip to main content
Version: 5.x.x

Socket


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

Description

Defined in socket/socket.ts:30

Parameters

NameDetails

options

Required

SocketOptionsType<AdapterType>

Properties

adapter

Description

Defined in socket/socket.ts:52

Type

ReturnType<AdapterType>

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>(endpoint: string, __namedParameters: { data: ResponseType; extra: any }) => void; emitListenerRemoveEvent: (endpoint: 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; onEmitterEventByEndpoint: <EmitterType>(emitter: EmitterType, callback: (emitter: EmitterType) => void) => VoidFunction; onError: (callback: <ResponseType>(event: ResponseType) => void) => VoidFunction; onListenerEvent: <ResponseType>(callback: (__namedParameters: { data: ResponseType; endpoint: string; extra: any }) => void) => VoidFunction; onListenerEventByEndpoint: <ListenerType>(listener: ListenerType, callback: (__namedParameters: { data: ResponseType; endpoint: string; extra: any }) => void) => VoidFunction; onListenerRemove: (callback: (endpoint: string) => void) => VoidFunction; onListenerRemoveByEndpoint: <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

SocketOptionsType<AdapterType>

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<AdapterType>>[]

__onErrorCallbacks

Description

Defined in socket/socket.ts:49

Type

ErrorCallbackType<Socket<AdapterType>, any>[]

__onMessageCallbacks

Description

Defined in socket/socket.ts:47

Type

MessageCallbackType<Socket<AdapterType>, any>[]

__onOpenCallbacks

Description

Defined in socket/socket.ts:43

Type

OpenCallbackType<Socket<AdapterType>>[]

__onReconnectCallbacks

Description

Defined in socket/socket.ts:45

Type

ReconnectCallbackType<Socket<AdapterType>>[]

__onReconnectStopCallbacks

Description

Defined in socket/socket.ts:46

Type

ReconnectStopCallbackType<Socket<AdapterType>>[]

__onSendCallbacks

Description

Defined in socket/socket.ts:48

Type

SendCallbackType<EmitterInstance>[]

Methods

createEmitter()

Preview

createEmitter<Payload, Response>()

Description

Create event emitter

Defined in socket/socket.ts:249

Return

(options: EmitterOptionsType<Endpoint, AdapterType>) => Emitter<Payload, Response, Endpoint, AdapterType, void, false, false>

createListener()

Preview

createListener<Response>()

Description

Create event listener

Defined in socket/socket.ts:238

Return

(options: ListenerOptionsType<Endpoint, AdapterType>) => Listener<Response, Endpoint, AdapterType, false>

onClose()

Preview

onClose(callback)

Description

Triggered when connection is closed

Defined in socket/socket.ts:158

Parameters

NameDetails

callback

Required

CloseCallbackType<Socket<AdapterType>>

Return

Socket<AdapterType>

onError()

Preview

onError<Event>(callback)

Description

Triggered when we receive error

Defined in socket/socket.ts:208

Parameters

NameDetails

callback

Required

ErrorCallbackType<Socket<AdapterType>, Event>

Return

Socket<AdapterType>

onMessage()

Preview

onMessage<Event>(callback)

Description

Triggered when any message is received

Defined in socket/socket.ts:188

Parameters

NameDetails

callback

Required

MessageCallbackType<Socket<AdapterType>, Event>

Return

Socket<AdapterType>

onOpen()

Preview

onOpen(callback)

Description

Triggered when connection is opened

Defined in socket/socket.ts:149

Parameters

NameDetails

callback

Required

OpenCallbackType<Socket<AdapterType>>

Return

Socket<AdapterType>

onReconnect()

Preview

onReconnect(callback)

Description

Triggered when connection is getting reconnected

Defined in socket/socket.ts:168

Parameters

NameDetails

callback

Required

ReconnectCallbackType<Socket<AdapterType>>

Return

Socket<AdapterType>

onReconnectStop()

Preview

onReconnectStop(callback)

Description

Triggered when connection attempts are stopped

Defined in socket/socket.ts:178

Parameters

NameDetails

callback

Required

ReconnectStopCallbackType<Socket<AdapterType>>

Return

Socket<AdapterType>

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<AdapterType>

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<AdapterType>) => 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(data)

Description

Defined in socket/socket.ts:223

Parameters

NameDetails

data

Required

{ data: any; extra: ExtractSocketExtraType<AdapterType> }

Return

{
data: any;
extra: any;
}

__modifySend()

Preview

__modifySend(emitter)

Description


Interceptors


Defined in socket/socket.ts:219

Parameters

NameDetails

emitter

Required

EmitterInstance

Return

Emitter<any, any, any, SocketAdapterInstance, any, any, any>