mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-28 00:53:31 +02:00
[Client] Fix bug, some refactorings
This commit is contained in:
parent
7eeb9c4962
commit
de5dc87cec
3 changed files with 30 additions and 16 deletions
|
@ -45,6 +45,8 @@ class Connection {
|
|||
}
|
||||
|
||||
send(message) {
|
||||
// TODO: バッファリングしてつぎ接続した時に送信する
|
||||
if (this.state != 'connected') return;
|
||||
this.socket.send(JSON.stringify(message));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
Loading…
Reference in a new issue