summaryrefslogtreecommitdiff
path: root/src/client/app/common/scripts/streaming
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/app/common/scripts/streaming')
-rw-r--r--src/client/app/common/scripts/streaming/games/reversi/reversi-game.ts6
-rw-r--r--src/client/app/common/scripts/streaming/hashtag.ts13
-rw-r--r--src/client/app/common/scripts/streaming/local-timeline.ts4
-rw-r--r--src/client/app/common/scripts/streaming/stream-manager.ts3
-rw-r--r--src/client/app/common/scripts/streaming/stream.ts4
5 files changed, 23 insertions, 7 deletions
diff --git a/src/client/app/common/scripts/streaming/games/reversi/reversi-game.ts b/src/client/app/common/scripts/streaming/games/reversi/reversi-game.ts
index e6b02fcfdb..adfa75ff3b 100644
--- a/src/client/app/common/scripts/streaming/games/reversi/reversi-game.ts
+++ b/src/client/app/common/scripts/streaming/games/reversi/reversi-game.ts
@@ -3,8 +3,10 @@ import MiOS from '../../../../../mios';
export class ReversiGameStream extends Stream {
constructor(os: MiOS, me, game) {
- super(os, 'games/reversi-game', {
- i: me ? me.token : null,
+ super(os, 'games/reversi-game', me ? {
+ i: me.token,
+ game: game.id
+ } : {
game: game.id
});
}
diff --git a/src/client/app/common/scripts/streaming/hashtag.ts b/src/client/app/common/scripts/streaming/hashtag.ts
new file mode 100644
index 0000000000..276b8f8d3d
--- /dev/null
+++ b/src/client/app/common/scripts/streaming/hashtag.ts
@@ -0,0 +1,13 @@
+import Stream from './stream';
+import MiOS from '../../../mios';
+
+export class HashtagStream extends Stream {
+ constructor(os: MiOS, me, q) {
+ super(os, 'hashtag', me ? {
+ i: me.token,
+ q: JSON.stringify(q)
+ } : {
+ q: JSON.stringify(q)
+ });
+ }
+}
diff --git a/src/client/app/common/scripts/streaming/local-timeline.ts b/src/client/app/common/scripts/streaming/local-timeline.ts
index 2834262bdc..41c36aa14c 100644
--- a/src/client/app/common/scripts/streaming/local-timeline.ts
+++ b/src/client/app/common/scripts/streaming/local-timeline.ts
@@ -7,9 +7,9 @@ import MiOS from '../../../mios';
*/
export class LocalTimelineStream extends Stream {
constructor(os: MiOS, me) {
- super(os, 'local-timeline', {
+ super(os, 'local-timeline', me ? {
i: me.token
- });
+ } : {});
}
}
diff --git a/src/client/app/common/scripts/streaming/stream-manager.ts b/src/client/app/common/scripts/streaming/stream-manager.ts
index 568b8b0372..8dd06f67d3 100644
--- a/src/client/app/common/scripts/streaming/stream-manager.ts
+++ b/src/client/app/common/scripts/streaming/stream-manager.ts
@@ -1,6 +1,7 @@
import { EventEmitter } from 'eventemitter3';
import * as uuid from 'uuid';
import Connection from './stream';
+import { erase } from '../../../../../prelude/array';
/**
* ストリーム接続を管理するクラス
@@ -89,7 +90,7 @@ export default abstract class StreamManager<T extends Connection> extends EventE
* @param userId use で発行したユーザーID
*/
public dispose(userId) {
- this.users = this.users.filter(id => id != userId);
+ this.users = erase(userId, this.users);
this._connection.user = `Managed (${ this.users.length })`;
diff --git a/src/client/app/common/scripts/streaming/stream.ts b/src/client/app/common/scripts/streaming/stream.ts
index fefa8e5ced..4ab78f1190 100644
--- a/src/client/app/common/scripts/streaming/stream.ts
+++ b/src/client/app/common/scripts/streaming/stream.ts
@@ -44,11 +44,11 @@ export default class Connection extends EventEmitter {
const query = params
? Object.keys(params)
- .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
+ .map(k => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
.join('&')
: null;
- this.socket = new ReconnectingWebsocket(`${wsUrl}/${endpoint}${query ? '?' + query : ''}`);
+ this.socket = new ReconnectingWebsocket(`${wsUrl}/${endpoint}${query ? `?${query}` : ''}`);
this.socket.addEventListener('open', this.onOpen);
this.socket.addEventListener('close', this.onClose);
this.socket.addEventListener('message', this.onMessage);