You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -249,14 +249,15 @@ See the example in [examples/reconnection](examples/reconnection).
249
249
250
250
## wsHooks
251
251
252
-
On websocket events, the following hooks are available, note **the hooks are all synchronous**.
252
+
On websocket events, the following hooks are available, note **the hooks are all synchronous**.
253
+
The `context` object is passed to all hooks and contains the `log` property.
253
254
254
-
-`onIncomingMessage`: A hook function that is called when the request is received from the client `onIncomingMessage(source, target, { data, binary })` (default: `undefined`).
255
-
-`onOutgoingMessage`: A hook function that is called when the response is received from the target `onOutgoingMessage(source, target, { data, binary })` (default: `undefined`).
255
+
-`onIncomingMessage`: A hook function that is called when the request is received from the client `onIncomingMessage(context, source, target, { data, binary })` (default: `undefined`).
256
+
-`onOutgoingMessage`: A hook function that is called when the response is received from the target `onOutgoingMessage(context, source, target, { data, binary })` (default: `undefined`).
256
257
-`onConnect`: A hook function that is called when the connection is established `onConnect(source, target)` (default: `undefined`).
257
-
-`onDisconnect`: A hook function that is called when the connection is closed `onDisconnect(source)` (default: `undefined`).
258
-
-`onReconnect`: A hook function that is called when the connection is reconnected `onReconnect(source, target)` (default: `undefined`). The function is called if reconnection feature is enabled.
259
-
-`onPong`: A hook function that is called when the target responds to the ping `onPong(source, target)` (default: `undefined`). The function is called if reconnection feature is enabled.
258
+
-`onDisconnect`: A hook function that is called when the connection is closed `onDisconnect(context, source)` (default: `undefined`).
259
+
-`onReconnect`: A hook function that is called when the connection is reconnected `onReconnect(context, source, target)` (default: `undefined`). The function is called if reconnection feature is enabled.
260
+
-`onPong`: A hook function that is called when the target responds to the ping `onPong(context, source, target)` (default: `undefined`). The function is called if reconnection feature is enabled.
0 commit comments