-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathbase-service.js
43 lines (37 loc) · 895 Bytes
/
base-service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class BaseServiceSocket {
/**
* @param {import('net').Socket} socketClient
*/
constructor(socketClient) {
this._socketClient = socketClient;
}
_assignClientFailureHandlers(...sourceStreams) {
for (const evt in ['close', 'end']) {
this._socketClient.once(evt,
() => sourceStreams.map((s) => s.unpipe(this._socketClient)));
}
}
/**
* Closes the underlying socket communicating with the phone
*/
close() {
if (!this._socketClient.destroyed) {
this._socketClient.end();
}
}
}
class BaseServicePlist {
/**
* @param {import('./plist-service').PlistService} plistService
*/
constructor(plistService) {
this._plistService = plistService;
}
/**
* Closes the underlying socket communicating with the phone
*/
close() {
this._plistService.close();
}
}
export { BaseServiceSocket, BaseServicePlist };