@@ -2,21 +2,21 @@ import { Subject, BehaviorSubject } from 'rxjs';
2
2
3
3
export default class Daemon {
4
4
constructor ( ) {
5
- this . socket = null ;
5
+ this . _socket = null ;
6
6
this . pluginURL = null ;
7
- this . messageBus = new Subject ( ) ;
7
+ this . socket = new Subject ( ) ;
8
8
this . serialMonitor = new Subject ( ) ;
9
9
this . devicesList = new BehaviorSubject ( {
10
10
serial : [ ] ,
11
11
network : [ ]
12
12
} ) ;
13
- this . messageBus . subscribe ( this . updateDevicesList . bind ( this ) ) ;
13
+ this . socket . subscribe ( this . updateDevicesList . bind ( this ) ) ;
14
14
this . openingSerial = null ;
15
15
this . closingSerial = null ;
16
16
}
17
17
18
18
initSocket ( ) {
19
- this . socket . on ( 'message' , this . parseMessage . bind ( this ) ) ;
19
+ this . _socket . on ( 'message' , this . parseMessage . bind ( this ) ) ;
20
20
}
21
21
22
22
initPluginUrl ( pluginUrl ) {
@@ -56,10 +56,10 @@ export default class Daemon {
56
56
57
57
parseMessage ( message ) {
58
58
try {
59
- this . messageBus . next ( JSON . parse ( message ) ) ;
59
+ this . socket . next ( JSON . parse ( message ) ) ;
60
60
}
61
61
catch ( SyntaxError ) {
62
- this . messageBus . next ( message ) ;
62
+ this . socket . next ( message ) ;
63
63
}
64
64
}
65
65
@@ -85,12 +85,12 @@ export default class Daemon {
85
85
return reject ( new Error ( 'Failed to open serial' ) ) ;
86
86
}
87
87
} ;
88
- this . openSubscription = this . messageBus . subscribe ( checkOpen ) ;
88
+ this . openSubscription = this . socket . subscribe ( checkOpen ) ;
89
89
} ) . finally ( ( ) => {
90
90
this . openSubscription . unsubscribe ( ) ;
91
91
this . openingSerial = null ;
92
92
} ) ;
93
- this . socket . emit ( 'command' , `open ${ port } 9600 timed` ) ;
93
+ this . _socket . emit ( 'command' , `open ${ port } 9600 timed` ) ;
94
94
return this . openingSerial ;
95
95
}
96
96
@@ -118,12 +118,12 @@ export default class Daemon {
118
118
return reject ( new Error ( 'Failed to close serial' ) ) ;
119
119
}
120
120
} ;
121
- this . closeSubscription = this . messageBus . subscribe ( checkClosed ) ;
121
+ this . closeSubscription = this . socket . subscribe ( checkClosed ) ;
122
122
} ) . finally ( ( ) => {
123
123
this . closeSubscription . unsubscribe ( ) ;
124
124
this . closingSerial = null ;
125
125
} ) ;
126
- this . socket . emit ( 'command' , `close ${ port } ` ) ;
126
+ this . _socket . emit ( 'command' , `close ${ port } ` ) ;
127
127
return this . closingSerial ;
128
128
}
129
129
@@ -134,7 +134,7 @@ export default class Daemon {
134
134
}
135
135
} ;
136
136
if ( ! this . readSerialSubscription ) {
137
- this . readSerialSubscription = this . messageBus . subscribe ( onMessage ) ;
137
+ this . readSerialSubscription = this . socket . subscribe ( onMessage ) ;
138
138
}
139
139
}
140
140
}
0 commit comments