ohmyvibe 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daemon/managementBridge.js +25 -5
- package/dist/daemon/sessionManager.js +97 -869
- package/dist/daemon/sessionRuntime.js +850 -0
- package/dist/daemon/sessionStore.js +70 -12
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ export class ManagementBridge {
|
|
|
8
8
|
sessionManager;
|
|
9
9
|
socket;
|
|
10
10
|
reconnectTimer;
|
|
11
|
+
eventFlushTimer;
|
|
12
|
+
pendingEvents = [];
|
|
11
13
|
constructor(sessionManager, options) {
|
|
12
14
|
this.sessionManager = sessionManager;
|
|
13
15
|
this.serverUrl = options.serverUrl;
|
|
@@ -17,11 +19,7 @@ export class ManagementBridge {
|
|
|
17
19
|
start() {
|
|
18
20
|
this.connect();
|
|
19
21
|
this.sessionManager.on("event", (event) => {
|
|
20
|
-
this.
|
|
21
|
-
type: "daemon-event",
|
|
22
|
-
daemonId: this.daemonId,
|
|
23
|
-
event,
|
|
24
|
-
});
|
|
22
|
+
this.enqueueEvent(event);
|
|
25
23
|
});
|
|
26
24
|
}
|
|
27
25
|
connect() {
|
|
@@ -83,6 +81,7 @@ export class ManagementBridge {
|
|
|
83
81
|
}, 3000);
|
|
84
82
|
}
|
|
85
83
|
sendHello() {
|
|
84
|
+
this.flushPendingEvents();
|
|
86
85
|
this.send({
|
|
87
86
|
type: "daemon-hello",
|
|
88
87
|
daemon: {
|
|
@@ -98,6 +97,27 @@ export class ManagementBridge {
|
|
|
98
97
|
sessions: this.sessionManager.list(),
|
|
99
98
|
});
|
|
100
99
|
}
|
|
100
|
+
enqueueEvent(event) {
|
|
101
|
+
this.pendingEvents.push(event);
|
|
102
|
+
if (this.eventFlushTimer) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.eventFlushTimer = setTimeout(() => {
|
|
106
|
+
this.eventFlushTimer = undefined;
|
|
107
|
+
this.flushPendingEvents();
|
|
108
|
+
}, 16);
|
|
109
|
+
}
|
|
110
|
+
flushPendingEvents() {
|
|
111
|
+
if (!this.pendingEvents.length) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const events = this.pendingEvents.splice(0, this.pendingEvents.length);
|
|
115
|
+
this.send({
|
|
116
|
+
type: "daemon-events",
|
|
117
|
+
daemonId: this.daemonId,
|
|
118
|
+
events,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
101
121
|
async handleRequest(method, params) {
|
|
102
122
|
switch (method) {
|
|
103
123
|
case "getConfig":
|