1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-10-31 23:31:48 +09:00

[Client] Fix bug, some refactorings

This commit is contained in:
syuilo 2017-03-20 14:35:00 +09:00
parent 7eeb9c4962
commit de5dc87cec
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 = () => {