summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts/streaming/home-stream.ts
blob: 11ad754ef06c9eabd88e2fdd4f3b662aa1ea857c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Stream from './stream';
import signout from '../signout';

/**
 * Home stream connection
 */
export default class Connection extends Stream {
	constructor(me) {
		super('', {
			i: me.token
		});

		// 最終利用日時を更新するため定期的にaliveメッセージを送信
		setInterval(() => {
			this.send({ type: 'alive' });
		}, 1000 * 60);

		// 自分の情報が更新されたとき
		this.on('i_updated', me.update);

		// トークンが再生成されたとき
		// このままではAPIが利用できないので強制的にサインアウトさせる
		this.on('my_token_regenerated', () => {
			alert('%i18n:common.my-token-regenerated%');
			signout();
		});
	}
}