mizzkey/src/web/app/common/scripts/home-stream.ts

28 lines
544 B
TypeScript
Raw Normal View History

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