mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-01 15:45:58 +09:00
✌️
This commit is contained in:
parent
8e9d5e8e2a
commit
56a1deb9d5
@ -22,6 +22,7 @@ export default class Connection extends EventEmitter {
|
|||||||
data: string
|
data: string
|
||||||
}> = [];
|
}> = [];
|
||||||
public id: string;
|
public id: string;
|
||||||
|
public isSuspended = false;
|
||||||
private os: MiOS;
|
private os: MiOS;
|
||||||
|
|
||||||
constructor(os: MiOS, endpoint, params?) {
|
constructor(os: MiOS, endpoint, params?) {
|
||||||
@ -91,6 +92,8 @@ export default class Connection extends EventEmitter {
|
|||||||
* Callback of when received a message from connection
|
* Callback of when received a message from connection
|
||||||
*/
|
*/
|
||||||
private onMessage(message) {
|
private onMessage(message) {
|
||||||
|
if (this.isSuspended) return;
|
||||||
|
|
||||||
if (this.os.debug) {
|
if (this.os.debug) {
|
||||||
this.in++;
|
this.in++;
|
||||||
this.inout.push({ type: 'in', at: new Date(), data: message.data });
|
this.inout.push({ type: 'in', at: new Date(), data: message.data });
|
||||||
@ -108,6 +111,8 @@ export default class Connection extends EventEmitter {
|
|||||||
* Send a message to connection
|
* Send a message to connection
|
||||||
*/
|
*/
|
||||||
public send(data) {
|
public send(data) {
|
||||||
|
if (this.isSuspended) return;
|
||||||
|
|
||||||
// まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する
|
// まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する
|
||||||
if (this.state != 'connected') {
|
if (this.state != 'connected') {
|
||||||
this.buffer.push(data);
|
this.buffer.push(data);
|
||||||
|
@ -94,6 +94,13 @@
|
|||||||
<el-tab-pane label="Streams (Inspect)">
|
<el-tab-pane label="Streams (Inspect)">
|
||||||
<el-tabs type="card" style="height:50%">
|
<el-tabs type="card" style="height:50%">
|
||||||
<el-tab-pane v-for="c in os.connections" :label="c.name == '' ? '[Home]' : c.name" :key="c.id" :name="c.id" ref="connectionsTab">
|
<el-tab-pane v-for="c in os.connections" :label="c.name == '' ? '[Home]' : c.name" :key="c.id" :name="c.id" ref="connectionsTab">
|
||||||
|
<div style="padding: 12px 0 0 12px">
|
||||||
|
<el-button size="mini" @click="send(c)">Send</el-button>
|
||||||
|
<el-button size="mini" type="warning" @click="c.isSuspended = true" v-if="!c.isSuspended">Suspend</el-button>
|
||||||
|
<el-button size="mini" type="success" @click="c.isSuspended = false" v-else>Resume</el-button>
|
||||||
|
<el-button size="mini" type="danger" @click="c.close">Disconnect</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
:data="c.inout"
|
:data="c.inout"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@ -177,6 +184,14 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
onWindowsChanged() {
|
onWindowsChanged() {
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
|
},
|
||||||
|
send(c) {
|
||||||
|
(this as any).apis.input({
|
||||||
|
title: 'Send a JSON message',
|
||||||
|
allowEmpty: false
|
||||||
|
}).then(json => {
|
||||||
|
c.send(JSON.parse(json));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user