onPrivateSubscribe callback. See #94 for details.EventEmitter import while building TypeScript project with definitions added in 2.2.0.presence() and presenceStats() responses in Protobuf format case. Those fields were not compliant with JSON format due to the fact that Protobuf compiler does not keep original case defined in proto schema by default. If you are using Protobuf this can be a breaking change - see this commit for fix details and all fields that now use snake_case instead of camelCase in Protobuf case. If you are using JSON you are not affected with these changeswebsocket option to explicitly provide custom WebSocket implementation to use2,147,483,647 which resulted in immediate refresh callback firing. Thi means that maximum possible TTL for JWT is about 25 days in Javascript.publish method of Centrifuge object to publish into channels without being subscribedsend method now sends message to server immediately and returns PromiseThis is a new major release of library updated to work with Centrifugo v2 and Centrifuge library. Library is now written using more actual Javascript instruments - with Webpack and ES6 classes. See readme for more information about new API and how to use library in general.
Highlights:
presenceStats method of subscriptiontrue after resubscribe on reconnect. See more details in #62unsubscribe sent from server - this is th remaining part of #46{
"channels": [
{
"channel": "$one",
"sign": "..."
}
]
}
I.e. object with channels on top level which is an array of objects with channel data. This resolves issues with API generators that do not support map on top level. This is also a bit more extendable and most probably will be default format in v2.
withCredentials support for XHR requests - #39.onRefresh and onPrivateChannelAuth callback functions to config to replace built-in refresh and private channel auth behaviour with you own logic. See #45 for motivation and initial pull request sent by @skyborn8onTransportClose callback should be executed every time transport was closed - see #33 for motivation.recovered flag in successful subscribe event context. It indicates that Centrifugo thinks all messages were successfully recovered (i.e. client did not miss any messages) after successful resubscribe on channel. See https://github.com/centrifugal/centrifugo/issues/165 for motivation.So it's possible to use it like this:
function handleSubscribe(ctx) {
console.log('Subscribed on channel ' + ctx.channel);
if (ctx.isResubscribe && !ctx.recovered) {
console.log("you need to restore messages from app backend");
} else {
console.log("no need to restore state");
}
}
var sub = centrifuge.subscribe(channel, handleMessage).on("subscribe", handleSubscribe)
Note that asking your backend about actual state after every reconnect is still the most reliable way to recover your app state. Relying on recovered flag can be an acceptable trade off for some applications though.
es6-promise dependency to ^4.0.5ping field from connect message as it not used by Centrifugo >= 1.6.3It's recommended to update SockJS library to latest version - 1.1.2
This release works with Centrifugo >= 1.6.0
Ping will be sent to server only when connection was idle - i.e. if there was no wire activity
for pingInterval period so it should not affect performance much.
You can disable automatic pings using "ping": false option. But before turning it off make
sure you've read chapter about pings in docs.
Also there is an adjustable pongWaitTimeout option to control how long to wait for pong
response before closing connection.
sockJS option to explicitly provide SockJS client objectsrc/centrifuge.js now to prevent webpack warning.ES6 example:
import Centrifuge from 'centrifuge'
import SockJS from 'sockjs-client'
var c = new Centrifuge({
"url": "...",
"user": "...",
"token": "...",
"timestamp": "...",
"sockJS": SockJS
});
c.connect();
refreshData option to send extra data in body when sending AJAX POST refresh requestrefreshAttempts option to limit amount of refresh requests before giving uprefreshFailed options to set callback function called when refreshAttempts came to the end.window object, so using self instead of window when we in SharedWorker context.subscribe for existing subscription if its in unsubscribed state.centrifuge.subscribe method when calling on channel for which subscriptionlatency field (in milliseconds) to connect event context. This measures time passedconnect client protocol command and receiving connect response.Also there was debug logging statement in 1.3.0 left in source code occasionally. 1.3.0 was rebuilt
with fix, but I am not sure that it was not cached somewhere in bower. So here is 1.3.1
Client API completely refactored in this release. You can still use previous versions
to communicate with Centrifugo server from browser environment but new implementation much
more comfortable to use in our opinion and will be supported in future releases so consider
upgrading!
Highlights of this release:
connect event handlerPlease, read new documentation
for Javascript browser client.
Also, DOM plugin was removed from repository as new client API design solves most of problems
that DOM plugin existed for - i.e. abstracting subscribe on many channels and automatically
resubscribe on them. With new client you can have one global connection to Centrifugo and
subscribe on channels at any moment from any part of your javascript code.
Also we updated examples to fit new changes.
If you are searching for old API docs (centrifuge-js <= 1.2.0) - you can find it here
recover option (introduced in Centrifugo v1.2.0)One backwards incompatible change here. Centrifuge-js now sends JSON (application/json)
request instead of application/x-www-form-urlencoded when client wants to subscribe on
private channel. See in docs how to deal with JSON in this case.
The only change in 0.9.0 is changing private channel request POST parameter namechannels to channels[]. If you are using private channels then you should update
your backend code to fit new parameter name. This change was required because of how
PHP and Ruby on Rails handle POST parameter names when POST request contains multiple
values for the same parameter name.
channels parameter renamed to channels[] in private subscription POST request to application.transports instead of protocols_whitelist.url without endpoint path provided