snapper-consumer
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -63,2 +63,6 @@ // **License:** MIT | ||
Consumer.prototype.getToken = function () { | ||
return this.options.token | ||
} | ||
Consumer.prototype.connect = function (url, options) { | ||
@@ -69,4 +73,6 @@ var ctx = this | ||
if (options) this.options = options | ||
if (this.options.token && !this.options.query) this.options.query = 'token=' + this.options.token | ||
var token = this.getToken() | ||
if (token) this.options.query = 'token=' + token | ||
if (this.connection) { | ||
@@ -73,0 +79,0 @@ this.connection.off() |
@@ -6,3 +6,3 @@ { | ||
"typings": "./snapper-consumer.d.ts", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"authors": [ | ||
@@ -9,0 +9,0 @@ "Yan Qing <admin@zensh.com>" |
@@ -59,3 +59,3 @@ snapper-consumer | ||
### new Consumer([url][, options]) | ||
### `new Consumer([url][, options])` | ||
@@ -68,7 +68,7 @@ ```js | ||
### consumer.prototype.onopen() | ||
### `consumer.prototype.onopen()` | ||
### consumer.prototype.onclose() | ||
### `consumer.prototype.onclose()` | ||
### consumer.prototype.onerror(error) | ||
### `consumer.prototype.onerror(error)` | ||
@@ -79,3 +79,3 @@ - `error`: `Error Object`. | ||
### consumer.prototype.onmessage(event) | ||
### `consumer.prototype.onmessage(event)` | ||
@@ -88,4 +88,13 @@ - `event.id`: `String|Number|null|undefined`, JSON-RPC id | ||
### consumer.prototype.request(method[, params][, callback]) | ||
### `consumer.prototype.getToken()` | ||
Default `getToken`, overwrite it in production. | ||
```js | ||
Consumer.prototype.getToken = function () { | ||
return this.options.token | ||
} | ||
``` | ||
### `consumer.prototype.request(method[, params][, callback])` | ||
- `method`: `String`, JSON-RPC request method. | ||
@@ -97,3 +106,3 @@ - `params`: `Mixed`, JSON-RPC request params. | ||
### consumer.prototype.join(room), consumer.prototype._join(room, consumerId) | ||
### `consumer.prototype.join(room), consumer.prototype._join(room, consumerId)` | ||
@@ -104,7 +113,7 @@ - `room`: `String`, room name. | ||
### consumer.prototype._respond(event) | ||
### `consumer.prototype._respond(event)` | ||
It is used to respond server's request. | ||
### consumer.prototype.connect([url][, options]) | ||
### `consumer.prototype.connect([url][, options])` | ||
@@ -116,4 +125,4 @@ - `url`: `String`, Snapper server host. | ||
### consumer.prototype.close() | ||
### `consumer.prototype.close()` | ||
Close the client. |
11016
201
122