Minimum version of Core Lib 2.2.4
The server must use centrifuge version 4
!!! To switch to v4, use the built-in config migration tool:
Centrifugo v4 development was concentrated around two main things:
When using the addition of live conversations or threads, it does not go to the last message, but remains in the same position. On large forums, this causes discomfort.
Added new triggers and their handling, now you can inline your code while connecting to a socket and when you connected to it.
In case of successful connection Client states will transition like this:
disconnected (initial) -> connecting (on('connecting') called) -> connected (on('connected') called).
In case of already connected Client temporary lost a connection with a server and then successfully reconnected:
connected -> connecting (on('connecting') called) -> connected (on('connected') called).
In case of already connected Client temporary lost a connection with a server, but got a terminal error upon reconnection:
connected -> connecting (on('connecting') called) -> disconnected (on('disconnected') called).
In case of already connected Client came across terminal condition (for example, if during a connection token refresh application found that user has no permission to connect anymore):
connected -> disconnected (on('disconnected') called).
Both connecting and disconnected events have numeric code and human-readable string reason in their context, so you can look at them and find the exact reason why the Client went to the connecting state or to the disconnected state.
This diagram demonstrates possible Client state transitions:
The following events will be available soon:
subscribed - Called when subscribed to a server-side channel upon Client moving to connected state or during connection lifetime if server sends Subscribe push message.
subscribing - Called when existing connection lost (Client reconnects) or Client explicitly disconnected. Client continue keeping server-side subscription registry with stream position information where applicable.
unsubscribed - Called when server sent unsubscribe push or server-side subscription
publication
This diagram demonstrates possible Subscription state transitions: