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
+7-19Lines changed: 7 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
<!-- Note that this readme is embedded on API Documentation page within Streamr. Please don't use first-level headings (h1). You should write this document so that it will work both as a stand-alone document in the public GitHub repo and as a section in the API docs. -->
2
2
<aname="js-client"></a>
3
-
## Streamr JavaScript Client
3
+
## Streamr Javascript Client
4
4
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.
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
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.
8
8
@@ -12,24 +12,14 @@ 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.
21
-
22
15
### Usage
23
16
24
17
Here's a quick example. More detailed examples for the browser and node.js can be found [here](https://github.com/streamr-dev/streamr-client/tree/master/examples).
25
18
26
19
```javascript
27
20
// Create a StreamrClient instance
28
21
var client =newStreamrClient({
29
-
// Connection options can be omitted, these are the default values
30
-
server:'https://data.streamr.com',
31
-
autoConnect:true,
32
-
autoDisconnect:true
22
+
// See below for connection options
33
23
})
34
24
35
25
// Subscribe to a stream
@@ -60,19 +50,17 @@ counter | (optional) A sequence number for this message, if available.
60
50
61
51
Option | Default value | Description
62
52
------ | ------------- | -----------
63
-
server | api.streamr.com | Address of the server to connect to.
53
+
url | ws://www.streamr.com/api/v1/ws | Address of the Streamr websocket endpoint to connect to.
64
54
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
-
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
-
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
-
55
+
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()`.
68
56
69
57
### Resend options
70
58
71
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.
72
60
73
61
Option | Default value | Description
74
62
------ | ------------- | -----------
75
-
resend_all | undefined | Set to `true` if you want all the messages for the channel resent from the earliest available message.
63
+
resend_all | undefined | Set to `true` if you want all the messages for the stream resent from the earliest available message.
76
64
resend_last | undefined | Resend the previous `N` messages.
77
65
resend_from | undefined | Resend from a specific message number.
78
66
resend_from_time | undefined | Resend from a specific Date (or millisecond timestamp).
@@ -135,7 +123,7 @@ no_resend | | Fired after `resending` in case there was nothing to resend.
135
123
136
124
### Logging
137
125
138
-
The Streamr JavaScript client library supports [debug](https://github.com/visionmedia/debug) for logging.
126
+
The Streamr JS client library supports [debug](https://github.com/visionmedia/debug) for logging.
139
127
140
128
In node.js, start your app like this: `DEBUG=StreamrClient node your-app.js`
0 commit comments