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
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,9 @@ var sub = client.subscribe(
41
41
Option | Default value | Description
42
42
------ | ------------- | -----------
43
43
url | ws://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.
44
+
authKey | null | Define default authKey to use when none is specified in the call to `client.subscribe`.
44
45
autoConnect | true | If set to `true`, the client connects automatically on the first call to `subscribe()`. Otherwise an explicit call to `connect()` is required.
45
46
autoDisconnect | true | If set to `true`, the client automatically disconnects when the last stream is unsubscribed. Otherwise the connection is left open and can be disconnected explicitly by calling `disconnect()`.
46
-
authKey | null | Define default authKey to use when none is specified in the call to `client.subscribe`.
47
47
48
48
### Message handler callback
49
49
@@ -54,32 +54,35 @@ Argument | Description
54
54
message | A javascript object containing the message itself
55
55
metadata | Metadata for the message, for example `metadata.timestamp` etc.
56
56
57
-
### Resend options
58
-
59
-
Note that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.
60
-
61
-
Option | Default value | Description
62
-
------ | ------------- | -----------
63
-
resend_all | undefined | Set to `true` if you want all the messages for the stream resent from the earliest available message.
64
-
resend_last | undefined | Resend the previous `N` messages.
65
-
resend_from | undefined | Resend from a specific message number.
66
-
resend_from_time | undefined | Resend from a specific Date (or millisecond timestamp).
67
-
resend_to | undefined | Can be used in conjunction with `resend_from` to limit the end of the resend. By default it is the newest message.
68
-
69
57
### Methods
70
58
71
59
Name | Description
72
60
---- | -----------
73
61
connect() | Connects to the server, and also subscribes to any streams for which `subscribe()` has been called before calling `connect()`.
74
62
disconnect() | Disconnects from the server, clearing all subscriptions.
75
63
pause() | Disconnects from the server without clearing subscriptions.
76
-
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.
64
+
subscribe(options, callback) | Subscribes to a stream. Messages in this stream are passed to the `callback` function. See below for subscription options. Returns a `Subscription` object.
77
65
unsubscribe(Subscription) | Unsubscribes the given `Subscription`.
78
66
unsubscribeAll(`streamId`) | Unsubscribes all `Subscriptions` for `streamId`.
79
67
getSubscriptions(`streamId`) | Returns a list of `Subscriptions` for `streamId`.
80
68
bind(eventName, function) | Binds a `function` to an event called `eventName`
81
69
unbind(eventName, function) | Unbinds the `function` from events called `eventName`
82
70
71
+
### Subscription options
72
+
73
+
Note that only one of the resend options can be used for a particular subscription. The default functionality is to resend nothing, only subscribe to messages from the subscription moment onwards.
74
+
75
+
Name | Description
76
+
---- | -----------
77
+
stream | Stream id to subscribe to
78
+
authKey | User key or stream key that authorizes the subscription. If defined, overrides the client's `authKey`.
79
+
partition | Partition number to subscribe to. Defaults to the default partition (0).
80
+
resend_all | Set to `true` if you want all the messages for the stream resent from the earliest available message.
81
+
resend_last | Resend the previous `N` messages.
82
+
resend_from | Resend from a specific message number.
83
+
resend_from_time | Resend from a specific Date (or millisecond timestamp).
84
+
resend_to | Can be used in conjunction with `resend_from` to limit the end of the resend. By default it is the newest message.
85
+
83
86
### Binding to events
84
87
85
88
The client and the subscriptions can fire events as detailed below. You can bind to them using `bind`:
0 commit comments