Socket
import { Socket } from "@hyper-fetch/sockets"
Description
Defined in socket/socket.ts:30
Parameters
Name | Details |
---|---|
options
|
|
Properties
events
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 }
queryParamsStringify
queryParamsStringify
Description
Method to stringify query params from objects.
Defined in socket/socket.ts:63
Type
StringifyCallbackType
__onCloseCallbacks
__onCloseCallbacks
Description
Defined in socket/socket.ts:44
Type
CloseCallbackType<Socket<Adapter>, any>[]
__onErrorCallbacks
__onErrorCallbacks
Description
Defined in socket/socket.ts:49
Type
ErrorCallbackType<Socket<Adapter>, any>[]
__onMessageCallbacks
__onMessageCallbacks
Description
Defined in socket/socket.ts:47
Type
MessageCallbackType<Socket<Adapter>, any>[]
__onOpenCallbacks
__onOpenCallbacks
Description
Defined in socket/socket.ts:43
Type
OpenCallbackType<Socket<Adapter>, any>[]
__onReconnectCallbacks
__onReconnectCallbacks
Description
Defined in socket/socket.ts:45
Type
ReconnectCallbackType<Socket<Adapter>>[]
__onReconnectStopCallbacks
__onReconnectStopCallbacks
Description
Defined in socket/socket.ts:46
Type
ReconnectStopCallbackType<Socket<Adapter>>[]
__onSendCallbacks
__onSendCallbacks
Description
Defined in socket/socket.ts:48
Type
SendCallbackType<EmitterInstance>[]
Methods
createEmitter()
createEmitter()
Preview
createEmitter<Payload, Response>(options)
Description
Create event emitter
Defined in socket/socket.ts:247
Parameters
Name | Details |
---|---|
options
|
|
Return
Emitter<Payload, Response, Adapter, void>
createListener()
createListener()
Preview
createListener<Response>(options)
Description
Create event listener
Defined in socket/socket.ts:238
Parameters
Name | Details |
---|---|
options
|
|
Return
Listener<Response, Adapter>
onClose()
onClose()
Preview
onClose<Event>(callback)
Description
Triggered when connection is closed
Defined in socket/socket.ts:158
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
onError()
onError()
Preview
onError<Event>(callback)
Description
Triggered when we receive error
Defined in socket/socket.ts:208
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
onMessage()
onMessage()
Preview
onMessage<Event>(callback)
Description
Triggered when any message is received
Defined in socket/socket.ts:188
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
onOpen()
onOpen()
Preview
onOpen<Event>(callback)
Description
Triggered when connection is opened
Defined in socket/socket.ts:149
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
onReconnect()
onReconnect()
Preview
onReconnect(callback)
Description
Triggered when connection is getting reconnected
Defined in socket/socket.ts:168
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
onReconnectStop()
onReconnectStop()
Preview
onReconnectStop(callback)
Description
Triggered when connection attempts are stopped
Defined in socket/socket.ts:178
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
onSend()
onSend()
Preview
onSend<EmitterType>(callback)
Description
Triggered when any event is emitted
Defined in socket/socket.ts:198
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<Adapter>
setAuth()
setAuth()
Preview
setAuth(auth)
Description
Set the new auth data to the socket
Defined in socket/socket.ts:125
Parameters
Name | Details |
---|---|
auth
|
|
Return
this
setDebug()
setDebug()
Preview
setDebug(debug)
Description
This method enables the logger usage and display the logs in console
Defined in socket/socket.ts:101
Parameters
Name | Details |
---|---|
debug
|
|
Return
this
setLogger()
setLogger()
Preview
setLogger(callback)
Description
Set the new logger instance to the socket
Defined in socket/socket.ts:117
Parameters
Name | Details |
---|---|
callback
|
|
Return
this
setLoggerSeverity()
setLoggerSeverity()
Preview
setLoggerSeverity(severity)
Description
Set the logger severity of the messages displayed to the console
Defined in socket/socket.ts:109
Parameters
Name | Details |
---|---|
severity
|
|
Return
this
setQuery()
setQuery()
Preview
setQuery(queryParams)
Description
Set the new query data to the socket
Defined in socket/socket.ts:134
Parameters
Name | Details |
---|---|
queryParams
|
|
Return
this