[Client] Fix bug, some refactorings

This commit is contained in:
syuilo 2017-03-20 14:35:00 +09:00
parent 507edc2bc7
commit 30983f053e
3 changed files with 30 additions and 16 deletions

View file

@ -45,6 +45,8 @@ class Connection {
}
send(message) {
// TODO: バッファリングしてつぎ接続した時に送信する
if (this.state != 'connected') return;
this.socket.send(JSON.stringify(message));
}

View file

@ -364,13 +364,24 @@
}
};
this.on('mount', () => {
this.capture = () => {
this.stream.send({
type: 'capture',
id: this.p.id
});
this.stream.event.on('post-updated', this.onStreamPostUpdated);
};
this.decapture = () => {
this.stream.send({
type: 'decapture',
id: this.p.id
});
this.stream.event.off('post-updated', this.onStreamPostUpdated);
};
this.on('mount', () => {
this.capture();
if (this.p.text) {
const tokens = this.p.ast;
@ -393,12 +404,7 @@
});
this.on('unmount', () => {
this.stream.send({
type: 'decapture',
id: this.p.id
});
this.stream.event.off('post-updated', this.onStreamPostUpdated);
this.decapture();
});
this.reply = () => {

View file

@ -340,13 +340,24 @@
}
};
this.on('mount', () => {
this.capture = () => {
this.stream.send({
type: 'capture',
id: this.p.id
});
this.stream.event.on('post-updated', this.onStreamPostUpdated);
};
this.decapture = () => {
this.stream.send({
type: 'decapture',
id: this.p.id
});
this.stream.event.off('post-updated', this.onStreamPostUpdated);
};
this.on('mount', () => {
this.capture();
if (this.p.text) {
const tokens = this.p.ast;
@ -369,12 +380,7 @@
});
this.on('unmount', () => {
this.stream.send({
type: 'decapture',
id: this.p.id
});
this.stream.event.off('post-updated', this.onStreamPostUpdated);
this.decapture();
});
this.reply = () => {