jormungandr-bite/src/web/app/common/scripts/home-stream.ts

28 lines
544 B
TypeScript
Raw Normal View History

2017-06-08 10:03:54 -06:00
import Stream from './stream';
2017-08-28 08:47:43 -06:00
import signout from './signout';
2017-06-08 10:03:54 -06:00
/**
* Home stream connection
*/
class Connection extends Stream {
constructor(me) {
super('', {
i: me.token
});
2017-08-30 02:45:23 -06:00
// 最終利用日時を更新するため定期的にaliveメッセージを送信
setInterval(() => {
this.send({ type: 'alive' });
}, 1000 * 60);
2017-11-13 02:05:35 -07:00
(this as any).on('i_updated', me.update);
2017-08-28 08:47:43 -06:00
2017-11-13 02:05:35 -07:00
(this as any).on('my_token_regenerated', () => {
2017-08-28 08:47:43 -06:00
alert('%i18n:common.my-token-regenerated%');
signout();
});
2017-06-08 10:03:54 -06:00
}
}
export default Connection;