summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts/stream.js
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-06-09 01:03:54 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-06-09 01:03:54 +0900
commit4e5545af384f610a56b3d19ea73c3b801b0be6c6 (patch)
tree4cd0b12e891bd1d8991ac4ad14cbbb7af83a0aee /src/web/app/common/scripts/stream.js
parentv2038 (diff)
downloadmisskey-4e5545af384f610a56b3d19ea73c3b801b0be6c6.tar.gz
misskey-4e5545af384f610a56b3d19ea73c3b801b0be6c6.tar.bz2
misskey-4e5545af384f610a56b3d19ea73c3b801b0be6c6.zip
nanka iroiro
Diffstat (limited to 'src/web/app/common/scripts/stream.js')
-rw-r--r--src/web/app/common/scripts/stream.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/web/app/common/scripts/stream.js b/src/web/app/common/scripts/stream.js
index ac3dd67153..981118b5de 100644
--- a/src/web/app/common/scripts/stream.js
+++ b/src/web/app/common/scripts/stream.js
@@ -5,10 +5,10 @@ import * as riot from 'riot';
import CONFIG from './config';
/**
- * Home stream connection
+ * Misskey stream connection
*/
class Connection {
- constructor(me) {
+ constructor(endpoint, params) {
// BIND -----------------------------------
this.onOpen = this.onOpen.bind(this);
this.onClose = this.onClose.bind(this);
@@ -20,16 +20,19 @@ class Connection {
riot.observable(this);
this.state = 'initializing';
- this.me = me;
this.buffer = [];
const host = CONFIG.apiUrl.replace('http', 'ws');
- this.socket = new ReconnectingWebSocket(`${host}?i=${me.token}`);
+ const query = params
+ ? Object.keys(params)
+ .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
+ .join('&')
+ : null;
+
+ this.socket = new ReconnectingWebSocket(`${host}/${endpoint}${query ? '?' + query : ''}`);
this.socket.addEventListener('open', this.onOpen);
this.socket.addEventListener('close', this.onClose);
this.socket.addEventListener('message', this.onMessage);
-
- this.on('i_updated', me.update);
}
/**