Fires whenever the transition opened->authorized happens.
Emits an auth response, when the isResponseSuccessful
field in WebSocketControllerConfig.authorize
is set, undefined otherwise.
Errors when either authorization response was not successful
(determined by the field isResponseSuccessful
of the WebSocketControllerConfig.authorize)
or authorization request
timed out (if so, will error with RxJs TimeoutError
).
Fires whenever the transition closing->closed happens.
Fires when the authorization, subscription or something else gone wrong. Does not replace notAuthorized$, notSubscribed$, error$ observables, they will emit anyway.
You can use it to navigate user back to login page.
Fires whenever the transition subscribed->closing happens.
Fires with socket, serialization and any other errors.
Generally there is no way to handle the errors, other than reopen socket, which is made internally. If you wish, you can log these errors or report them to the server via http.
Observable with all messages, received by the socket. Subscription does not affect opening and closing socket.
Fires whenever the transition pending->opened happens.
Fires whenever the transition closed->pending happens.
The WebSocketController is designed the way you do not need this field, but if you need, you could use it. WebSocketControllerState
Notifies about state transitions WebSocketControllerState
Fires whenever the transition authorized->subscribed happens.
Emits an auth subscribe responses, when the isResponseSuccessful
field in WebSocketControllerConfig.subscribe
is set, undefined otherwise.
Fires when one of the subscription responses was not successful
(determined by the field isResponseSuccessful
of the WebSocketControllerConfig.subscribe)
or when one of the requests timed out (if so, will error with RxJs TimeoutError
).
Closes the socket, cancels the reconnection.
Opens websocket and sets up reconnect according to the options.
Sends the message and waits for the corresponding response message. The response is found by id, so setRequestId(msg) === getResponseId(response). Those functions are configured in WebSocketControllerConfig.
By default, if the socket is not opened or authorized, the message is saved to the buffer, and being sent later, when the socket comes to an appropriate state. You also can control parameters of the buffer through WebSocketControllerConfig.buffer Note, that there are different buffers for messages, that require the socket to be authorized, and for those, that do not.
Unlike Angular HttpClient, the request is being sent immediately after the function was called, not after subscription to the inner observable.
The data to be serialized and sent.
Controls the authorization, usage of buffer, etc. WebSocketSendOptions
Sends the message into the underlying socket.
By default, if the socket is not opened or authorized, the message is saved to the buffer, and being sent later, when the socket comes to an appropriate state. You also can control parameters of the buffer through WebSocketControllerConfig.buffer Note, that there are different buffers for messages, that require the socket to be authorized, or to be subscribed, and for those, that do not.
The data to be serialized and sent.
Controls the authorization, usage of buffer, etc. WebSocketSendOptions.
Generated using TypeDoc
Class, that wraps the socket and takes control over authorization, subscription and reconnection.