@@ -17,10 +17,7 @@ export abstract class Connection {
17
17
private disposed = false ;
18
18
private _offline : number | undefined ;
19
19
20
- public constructor ( protected protocol : Protocol ) {
21
- protocol . onClose ( ( ) => this . dispose ( ) ) ; // Explicit close.
22
- protocol . onSocketClose ( ( ) => this . _offline = Date . now ( ) ) ; // Might reconnect.
23
- }
20
+ public constructor ( protected protocol : Protocol , public readonly token : string ) { }
24
21
25
22
public get offline ( ) : number | undefined {
26
23
return this . _offline ;
@@ -39,6 +36,12 @@ export abstract class Connection {
39
36
}
40
37
}
41
38
39
+ protected setOffline ( ) : void {
40
+ if ( ! this . _offline ) {
41
+ this . _offline = Date . now ( ) ;
42
+ }
43
+ }
44
+
42
45
/**
43
46
* Set up the connection on a new socket.
44
47
*/
@@ -50,6 +53,12 @@ export abstract class Connection {
50
53
* Used for all the IPC channels.
51
54
*/
52
55
export class ManagementConnection extends Connection {
56
+ public constructor ( protected protocol : Protocol , token : string ) {
57
+ super ( protocol , token ) ;
58
+ protocol . onClose ( ( ) => this . dispose ( ) ) ; // Explicit close.
59
+ protocol . onSocketClose ( ( ) => this . setOffline ( ) ) ; // Might reconnect.
60
+ }
61
+
53
62
protected doDispose ( ) : void {
54
63
this . protocol . sendDisconnect ( ) ;
55
64
this . protocol . dispose ( ) ;
@@ -66,11 +75,11 @@ export class ExtensionHostConnection extends Connection {
66
75
private process ?: cp . ChildProcess ;
67
76
68
77
public constructor (
69
- locale :string , protocol : Protocol , buffer : VSBuffer ,
78
+ locale :string , protocol : Protocol , buffer : VSBuffer , token : string ,
70
79
private readonly log : ILogService ,
71
80
private readonly environment : IEnvironmentService ,
72
81
) {
73
- super ( protocol ) ;
82
+ super ( protocol , token ) ;
74
83
this . protocol . dispose ( ) ;
75
84
this . spawn ( locale , buffer ) . then ( ( p ) => this . process = p ) ;
76
85
this . protocol . getUnderlyingSocket ( ) . pause ( ) ;
@@ -129,6 +138,9 @@ export class ExtensionHostConnection extends Connection {
129
138
const severity = ( < any > this . log ) [ event . severity ] ? event . severity : "info" ;
130
139
( < any > this . log ) [ severity ] ( "Extension host" , event . arguments ) ;
131
140
}
141
+ if ( event && event . type === "VSCODE_EXTHOST_DISCONNECTED" ) {
142
+ this . setOffline ( ) ;
143
+ }
132
144
} ) ;
133
145
134
146
const listen = ( message : IExtHostReadyMessage ) => {
0 commit comments