@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.
@@ -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
- return {
25
- status: null,
26
- body: null,
27
- raw: null,
28
- headers: null,
29
- writeHead(status, headers) { this.status = status; this.headers = headers },
30
- end(body) {
31
- if (Buffer.isBuffer(body)) this.raw = body
32
- else if (typeof body === 'string' && (this.headers ? String(this.headers['content-type']) : '').includes('json')) this.body = JSON.parse(body)
33
- else this.raw = body
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) {