In the previous chapter we investigated common principles of Centrifugo client SDK API. Here we will provide a list of available bidirectional connectors you can use to communicate with Centrifugo.
Client libraries listed here speak Centrifugo bidirectional protocol (WebSocket). If you aim to use unidirectional approach you don't need client connectors – just use standard APIs. See the difference here.
List of client SDKs
- centrifuge-js – for browser, NodeJS and React Native
- centrifuge-go - for Go language
- centrifuge-dart - for Dart and Flutter
- centrifuge-swift – for native iOS development
- centrifuge-java – for native Android development and general Java
See a description of client protocol if you want to write a custom bidirectional connector or eager to learn how Centrifugo protocol internals are structured.
Protobuf and JSON formats in SDKs
Centrifugo real-time SDKs work using two possible serialization formats: JSON and Protobuf. The entire bidirectional client protocol is described by the Protobuf schema. But those Protobuf messages may be also encoded as JSON objects (in JSON representation
bytes fields in the Protobuf schema is replaced by the embedded JSON object in Centrifugo case).
centrifuge-js - uses JSON serialization for protocol frames by default. This makes communication with Centrifugo server convenient as we are exchanging human-readable JSON frames between client and server. And it makes it possible to use
centrifuge-js without extra dependency to
protobuf.js library. It's possible to switch to Protobuf protocol with
centrifuge-js SDK though, in case you want more compact Centrifuge protocol representation, faster decode/encode speeds on Centrifugo server side, or payloads you need to pass are custom binary. See more details on how to use
centrifuge-js with Protobuf serialization in README.
centrifuge-go real-time SDK for Go language also supports both JSON and Protobuf formats when communicating with Centrifugo server.
Other SDKs, like
centrifuge-java work using only Protobuf serialization for Centrifuge protocol internally. So they utilize the fastest and the most compact wire representation by default. Note, that while internally in those SDKs the serialization format is Protobuf, you can still send JSON towards these clients as JSON objects may be encoded as UTF-8 bytes. So these SDKs may work with both custom binary and JSON payloads.
There are some important notes about JSON and Protobuf interoperability mentioned in our FAQ.
SDK feature matrix
Below you can find an information regarding support of different features in our official client SDKs
Connection related features
|connect to a server||✅||✅||✅||✅||✅|
|setting client options||✅||✅||✅||✅||✅|
|automatic reconnect with backoff algorithm||✅||✅||✅||✅||✅|
|client state changes||✅||✅||✅||✅||✅|
|connection token refresh||✅||✅||✅||✅||✅|
|handle disconnect advice from server||✅||✅||✅||✅||✅|
|bidirectional WebSocket emulation||✅|
Client-side subscription related features
|subscrbe to a channel||✅||✅||✅||✅||✅|
|setting subscription options||✅||✅||✅||✅||✅|
|automatic resubscribe with backoff algorithm||✅||✅||✅||✅||✅|
|subscription state changes||✅||✅||✅||✅||✅|
|subscription async pushes||✅||✅||✅||✅||✅|
|subscription token refresh||✅||✅||✅||✅||✅|
|handle unsubscribe advice from server||✅||✅||✅||✅||✅|
|manage subscription registry||✅||✅||✅||✅||✅|