@@ -10,7 +10,8 @@ import { ITempService } from "../../definitions/temp-service";
10
10
11
11
export class AppDebugSocketProxyFactory
12
12
extends EventEmitter
13
- implements IAppDebugSocketProxyFactory {
13
+ implements IAppDebugSocketProxyFactory
14
+ {
14
15
private deviceWebServers : IDictionary < ws . Server > = { } ;
15
16
private deviceTcpServers : IDictionary < net . Server > = { } ;
16
17
@@ -113,9 +114,8 @@ export class AppDebugSocketProxyFactory
113
114
projectName : string ,
114
115
projectDir : string
115
116
) : Promise < ws . Server > {
116
- const existingWebProxy = this . deviceWebServers [
117
- `${ device . deviceInfo . identifier } -${ appId } `
118
- ] ;
117
+ const existingWebProxy =
118
+ this . deviceWebServers [ `${ device . deviceInfo . identifier } -${ appId } ` ] ;
119
119
const result =
120
120
existingWebProxy ||
121
121
( await this . addWebSocketProxy ( device , appId , projectName , projectDir ) ) ;
@@ -218,6 +218,11 @@ export class AppDebugSocketProxyFactory
218
218
packets . on ( "data" , ( buffer : Buffer ) => {
219
219
const message = buffer . toString ( encoding ) ;
220
220
if ( webSocket . readyState === webSocket . OPEN ) {
221
+ if ( process . env . DEBUG_DEVTOOLS_SOCKETS ) {
222
+ console . log ( {
223
+ msgFromRuntime : JSON . parse ( message ) ,
224
+ } ) ;
225
+ }
221
226
webSocket . send ( message ) ;
222
227
} else {
223
228
this . $logger . trace (
@@ -234,23 +239,29 @@ export class AppDebugSocketProxyFactory
234
239
this . $logger . trace ( "Error on debugger deviceSocket" , err ) ;
235
240
} ) ;
236
241
237
- webSocket . on ( "message" , ( message : string ) => {
238
- const length = Buffer . byteLength ( message , encoding ) ;
242
+ webSocket . on ( "message" , ( message ) => {
243
+ const msg = message . toString ( ) ;
244
+ if ( process . env . DEBUG_DEVTOOLS_SOCKETS ) {
245
+ console . log ( {
246
+ msgFromDevtools : JSON . parse ( msg ) ,
247
+ } ) ;
248
+ }
249
+ const length = Buffer . byteLength ( msg , encoding ) ;
239
250
const payload = Buffer . allocUnsafe ( length + 4 ) ;
240
251
payload . writeInt32BE ( length , 0 ) ;
241
- payload . write ( message , 4 , length , encoding ) ;
252
+ payload . write ( msg , 4 , length , encoding ) ;
242
253
appDebugSocket . write ( payload ) ;
243
254
} ) ;
244
255
245
256
appDebugSocket . on ( "close" , ( ) => {
246
257
currentAppSocket = null ;
247
- this . $logger . info ( "Backend socket closed!" ) ;
258
+ this . $logger . trace ( "Backend socket closed!" ) ;
248
259
webSocket . close ( ) ;
249
260
} ) ;
250
261
251
262
webSocket . on ( "close" , async ( ) => {
252
263
currentWebSocket = null ;
253
- this . $logger . info ( "Frontend socket closed!" ) ;
264
+ this . $logger . trace ( "Frontend socket closed!" ) ;
254
265
appDebugSocket . unpipe ( packets ) ;
255
266
packets . destroy ( ) ;
256
267
await device . destroyDebugSocket ( appId ) ;
0 commit comments