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>(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 }
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<AdapterType>>[]
__onErrorCallbacks
__onErrorCallbacks
Description
Defined in socket/socket.ts:49
Type
ErrorCallbackType<Socket<AdapterType>, any>[]
__onMessageCallbacks
__onMessageCallbacks
Description
Defined in socket/socket.ts:47
Type
MessageCallbackType<Socket<AdapterType>, any>[]
__onOpenCallbacks
__onOpenCallbacks
Description
Defined in socket/socket.ts:43
Type
OpenCallbackType<Socket<AdapterType>>[]
__onReconnectCallbacks
__onReconnectCallbacks
Description
Defined in socket/socket.ts:45
Type
ReconnectCallbackType<Socket<AdapterType>>[]
__onReconnectStopCallbacks
__onReconnectStopCallbacks
Description
Defined in socket/socket.ts:46
Type
ReconnectStopCallbackType<Socket<AdapterType>>[]
__onSendCallbacks
__onSendCallbacks
Description
Defined in socket/socket.ts:48
Type
SendCallbackType<EmitterInstance>[]
Methods
createEmitter()
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()
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()
onClose()
Preview
onClose(callback)
Description
Triggered when connection is closed
Defined in socket/socket.ts:158
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<AdapterType>
onError()
onError()
Preview
onError<Event>(callback)
Description
Triggered when we receive error
Defined in socket/socket.ts:208
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<AdapterType>
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<AdapterType>
onOpen()
onOpen()
Preview
onOpen(callback)
Description
Triggered when connection is opened
Defined in socket/socket.ts:149
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<AdapterType>
onReconnect()
onReconnect()
Preview
onReconnect(callback)
Description
Triggered when connection is getting reconnected
Defined in socket/socket.ts:168
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<AdapterType>
onReconnectStop()
onReconnectStop()
Preview
onReconnectStop(callback)
Description
Triggered when connection attempts are stopped
Defined in socket/socket.ts:178
Parameters
Name | Details |
---|---|
callback
|
|
Return
Socket<AdapterType>
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<AdapterType>
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