@@ -17,10 +17,7 @@ export abstract class Connection {
1717 private disposed = false ;
1818 private _offline : number | undefined ;
1919
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 ) { }
2421
2522 public get offline ( ) : number | undefined {
2623 return this . _offline ;
@@ -39,6 +36,12 @@ export abstract class Connection {
3936 }
4037 }
4138
39+ protected setOffline ( ) : void {
40+ if ( ! this . _offline ) {
41+ this . _offline = Date . now ( ) ;
42+ }
43+ }
44+
4245 /**
4346 * Set up the connection on a new socket.
4447 */
@@ -50,6 +53,12 @@ export abstract class Connection {
5053 * Used for all the IPC channels.
5154 */
5255export 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+
5362 protected doDispose ( ) : void {
5463 this . protocol . sendDisconnect ( ) ;
5564 this . protocol . dispose ( ) ;
@@ -66,11 +75,11 @@ export class ExtensionHostConnection extends Connection {
6675 private process ?: cp . ChildProcess ;
6776
6877 public constructor (
69- locale :string , protocol : Protocol , buffer : VSBuffer ,
78+ locale :string , protocol : Protocol , buffer : VSBuffer , token : string ,
7079 private readonly log : ILogService ,
7180 private readonly environment : IEnvironmentService ,
7281 ) {
73- super ( protocol ) ;
82+ super ( protocol , token ) ;
7483 this . protocol . dispose ( ) ;
7584 this . spawn ( locale , buffer ) . then ( ( p ) => this . process = p ) ;
7685 this . protocol . getUnderlyingSocket ( ) . pause ( ) ;
@@ -129,6 +138,9 @@ export class ExtensionHostConnection extends Connection {
129138 const severity = ( < any > this . log ) [ event . severity ] ? event . severity : "info" ;
130139 ( < any > this . log ) [ severity ] ( "Extension host" , event . arguments ) ;
131140 }
141+ if ( event && event . type === "VSCODE_EXTHOST_DISCONNECTED" ) {
142+ this . setOffline ( ) ;
143+ }
132144 } ) ;
133145
134146 const listen = ( message : IExtHostReadyMessage ) => {
0 commit comments