@mzzsfy/dsh-turn-notify 0.9.0 → 0.11.0
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/README.md +23 -7
- package/package.json +2 -2
- package/src/client.js +204 -7
- package/src/core.mjs +122 -4
- package/src/index.js +93 -7
- package/test/client-fold.test.mjs +405 -0
- package/test/core.test.mjs +9 -0
- package/test/event-wiring.test.mjs +7 -6
- package/test/flow.test.mjs +15 -5
- package/test/host-notify.test.mjs +593 -0
- package/test/sounds.route.test.mjs +12 -11
|
@@ -20,19 +20,20 @@ const soundsDir = join(homeRoot, '.dsh', 'dsh-turn-notify', 'sounds')
|
|
|
20
20
|
const JSON_HEADERS = { 'content-type': 'application/json' }
|
|
21
21
|
const WAV_BYTES = Buffer.from([1, 2, 3, 4])
|
|
22
22
|
|
|
23
|
+
// res 桩带事件能力:投影处理器挂 close 事件感知断连,桩须支持 once
|
|
23
24
|
function makeRes() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
25
|
+
const res = new EventEmitter()
|
|
26
|
+
res.status = null
|
|
27
|
+
res.body = null
|
|
28
|
+
res.raw = null
|
|
29
|
+
res.headers = null
|
|
30
|
+
res.writeHead = (status, headers) => { res.status = status; res.headers = headers }
|
|
31
|
+
res.end = (body) => {
|
|
32
|
+
if (Buffer.isBuffer(body)) res.raw = body
|
|
33
|
+
else if (typeof body === 'string' && (res.headers ? String(res.headers['content-type']) : '').includes('json')) res.body = JSON.parse(body)
|
|
34
|
+
else res.raw = body
|
|
35
35
|
}
|
|
36
|
+
return res
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function makeReq(method, payload, headers, url) {
|