Skip to content

Releases: centrifugal/centrifuge-js

2.8.1

13 Sep 04:54
140950c

Choose a tag to compare

  • Support sockjsTimeout (number) option which translates to SockJS.timeout option - i.e. a minimum timeout in milliseconds to use for the transport connections. By default SockJS uses timeout determined automatically based on calculating round trip time during info request.

2.8.0

29 Aug 19:06
de7ba66

Choose a tag to compare

Update to work with Centrifuge >= v0.18.0 and Centrifugo v3.

Breaking change in server behavior. Client History API behavior changed in Centrifuge >= v0.18.0 and Centrifugo >= v3.0.0. When using history call it won't return all publications in a stream by default. See Centrifuge v0.18.0 release notes or Centrifugo v3 migration guide for more information and workaround on server-side. If you are using centrifuge-js with older server versions then everything without using history options like limit and since then everything should work the same way. Since this is a change in a server behavior we don't release a new major centrifuge-js version.

Other changes:

  • Protocol definitions updated to the latest version
  • When working with Centrifugo v3 or Centrifuge >= v0.18.0 it's now possible to avoid using ?format=protobuf in connection URL when using Protobuf protocol. The intent to use binary Protobuf protocol can now be set explicitly in client options. In this case client will negotiate Protobuf protocol with a server using WebSocket subprotocol mechanism (in request headers). Pull request.
  • It's now possible to call subscribe and provide custom subscribe options. One subscribe option available now is since – which allows setting known StreamPosition and initiate automatic recovery. Pull request.
  • Support history reverse option (Centrifuge >= v0.18.1 and Centrifugo v3 only)

2.7.7

28 Jul 08:32
da6187d

Choose a tag to compare

  • possibility to set disableWithCredentials boolean option (false by default) to control withCredentials option of XMLHttpRequest. See #155. Thanks to @yakimka

2.7.6

30 May 10:34
82c92f5

Choose a tag to compare

  • xmlhttprequest option to explicitly pass XMLHttpRequest (for NodeJS environment)

2.7.5

13 Apr 18:41

Choose a tag to compare

  • Fix regression of 2.7.4 - Unexpected end of JSON input

2.7.4

13 Apr 12:10

Choose a tag to compare

  • Optimize & simplify json encode/decode, see #138

2.7.3

31 Mar 10:54

Choose a tag to compare

  • SubscribeSuccessContext can contain data field if custom data returned from a server in a subscribe result.

2.7.2

03 Mar 20:23

Choose a tag to compare

  • Handle server-side SUB push in Protobuf case (previously ignored). Sub push is a message that contains information about server-side subscription made after connection already established.

2.7.1

16 Feb 14:22

Choose a tag to compare

  • Fix type definitions - see #133

2.7.0

06 Feb 15:25

Choose a tag to compare

  • add missing offset to TS definitions for PublicationContext, note that seq and gen fields considered deprecated and will go away with next major centrifuge-js release
  • add top-level methods: history, presence, presenceStats – those are useful when using sever-side subscriptions
  • fix wrong error format of top-level publish Promise reject branch – it now contains protocol error object (with code and message fields)
  • possibility to set name and version protocol fields over Centrifuge config options
  • remove unused promise option from configuration
  • add history iteration API (usage limited to Centrifuge library for Go at the moment) - see example below
  • subscribe success event context in positioned subscriptions (added in Centrifuge library v0.15.0) now contains streamPosition object (with current offset and epoch fields)
  • updated protobuf-js dependency (now ^6.10.2)
  • all dev-dependencies updated and now use the latest versions of webpack, babel, eslint, mocha etc
  • internal code refactoring of Subscrption methods - code is simplified and more reusable now

Let's look at history pagination feature in more detail. It's now possible to iterate over channel history this way:

resp = await subscription.history({'since': {'offset': 2, 'epoch': 'xcf4w'}, limit: 100});

If server can't fulfill a query for history (due to stream retention - size or expiration, or malformed offset, or stream already has another epoch) then an Unrecoverable Position Error will be returned (code 112).

To only call for current offset and epoch use:

resp = await subscription.history({limit: 0});

I.e. not providing since and using zero limit.

Due to backward compatibility history call without arguments will return full existing history in channel (though it's possible to limit max number of publications to return on server side).

For now history pagination feature only works with Centrifuge library based server and not available in Centrifugo.