You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
By using this client, you can easily subscribe to realtime [Streamr](http://www.streamr.com) streams from JavaScript-based environments, such as browsers and [node.js](https://nodejs.org). This enables you to use Streamr as an over-the-internet pub/sub engine with powerful analytics and automation features.
6
6
7
-
The client uses [socket.io](http://socket.io/) under the hood for streaming message delivery. It works in virtually all browsers by using websockets where available, or fallback methods on legacy browsers.
7
+
The client uses [web sockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) under the hood for streaming message delivery.
8
8
9
9
### Installation
10
10
@@ -14,7 +14,6 @@ The client is available on [npm](https://www.npmjs.com/package/streamr-client) a
In node.js, dependencies will be installed automatically with `npm install`. In the browser, make sure you include `socket.io-client` before `streamr-client` in your HTML.
@@ -35,6 +34,7 @@ var client = new StreamrClient({
35
34
// Subscribe to a stream
36
35
var sub =client.subscribe(
37
36
'stream-id',
37
+
'auth-key',
38
38
function(message, streamId, timestamp, counter) {
39
39
// Do something with a message, which is an object
40
40
},
@@ -46,7 +46,7 @@ var sub = client.subscribe(
46
46
47
47
### Handling messages
48
48
49
-
The second argument to `client.subscribe(streamId, callback, resendOptions)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:
49
+
The third argument to `client.subscribe(streamId, authKey, callback, resendOptions)` is the callback function that will be called for each message as they arrive. Its arguments are as follows:
50
50
51
51
Argument | Description
52
52
-------- | -----------
@@ -64,6 +64,7 @@ server | api.streamr.com | Address of the server to connect to.
64
64
autoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.
65
65
autoDisconnect | true | If set to `true`, the client automatically disconnects when the last channel is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.
66
66
transports | null | Override default transport selection / upgrade scheme. For example, value `["websocket"]` will force use of sockets right from the beginning, while value `["polling"]` will allow only long-polling to be used.
67
+
authKey | null | Define default authKey to use when none is specified in subscribe
67
68
68
69
69
70
### Resend options
@@ -85,7 +86,7 @@ Name | Description
85
86
connect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`.
86
87
disconnect() | Disconnects from the server, clearing all subscriptions.
87
88
pause() | Disconnects from the server without clearing subscriptions.
88
-
subscribe(streamId, callback, resendOptions) | Subscribes to a stream identified by the string `streamId`. Messages in this stream are passed to the `callback` function. See the above table for `resendOptions`. Returns a `Subscription` object.
89
+
subscribe(streamId, authId, callback, resendOptions) | Subscribes to a stream identified by the string `streamId`. Authentication key `authId` is used. Messages in this stream are passed to the `callback` function. See the above table for `resendOptions`. Returns a `Subscription` object.
89
90
unsubscribe(Subscription) | Unsubscribes the given `Subscription`.
90
91
unsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.
91
92
getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.
0 commit comments