@@ -19,13 +19,13 @@ interface IMessageArgs {
1919export class PostOffice implements IAsyncDisposable {
2020
2121 private name : string ;
22- private started : Promise < vsls . LiveShare | null > ;
23- private hostServer : vsls . SharedService | null = null ;
24- private guestServer : vsls . SharedServiceProxy | null = null ;
25- private currentRole : vsls . Role = vsls . Role . None ;
22+ private started : Promise < vsls . LiveShare | null > ;
23+ private hostServer : vsls . SharedService | null = null ;
24+ private guestServer : vsls . SharedServiceProxy | null = null ;
25+ private currentRole : vsls . Role = vsls . Role . None ;
2626 private currentPeerCount : number = 0 ;
27- private peerCountChangedEmitter : vscode . EventEmitter < number > = new vscode . EventEmitter < number > ( ) ;
28- private commandMap : { [ key : string ] : { thisArg : any ; callback ( ...args : any [ ] ) : void } } = { } ;
27+ private peerCountChangedEmitter : vscode . EventEmitter < number > = new vscode . EventEmitter < number > ( ) ;
28+ private commandMap : { [ key : string ] : { thisArg : any ; callback ( ...args : any [ ] ) : void } } = { } ;
2929
3030 constructor (
3131 name : string ,
@@ -41,7 +41,7 @@ export class PostOffice implements IAsyncDisposable {
4141 return this . currentPeerCount ;
4242 }
4343
44- public get peerCountChanged ( ) : vscode . Event < number > {
44+ public get peerCountChanged ( ) : vscode . Event < number > {
4545 return this . peerCountChangedEmitter . event ;
4646 }
4747
@@ -57,7 +57,7 @@ export class PostOffice implements IAsyncDisposable {
5757 this . guestServer = null ;
5858 }
5959
60- public async postCommand ( command : string , ...args : any [ ] ) : Promise < void > {
60+ public async postCommand ( command : string , ...args : any [ ] ) : Promise < void > {
6161 // Make sure startup finished
6262 const api = await this . started ;
6363 let skipDefault = false ;
@@ -88,7 +88,7 @@ export class PostOffice implements IAsyncDisposable {
8888 }
8989 }
9090
91- public async registerCallback ( command : string , callback : ( ...args : any [ ] ) => void , thisArg ?: any ) : Promise < void > {
91+ public async registerCallback ( command : string , callback : ( ...args : any [ ] ) => void , thisArg ?: any ) : Promise < void > {
9292 const api = await this . started ;
9393
9494 // For a guest, make sure to register the notification
@@ -100,11 +100,11 @@ export class PostOffice implements IAsyncDisposable {
100100 this . commandMap [ command ] = { callback, thisArg } ;
101101 }
102102
103- private createBroadcastArgs ( command : string , ...args : any [ ] ) : IMessageArgs {
103+ private createBroadcastArgs ( command : string , ...args : any [ ] ) : IMessageArgs {
104104 return { args : JSON . stringify ( [ command , ...args ] ) } ;
105105 }
106106
107- private translateArgs ( api : vsls . LiveShare , command : string , ...args : any [ ] ) : IMessageArgs {
107+ private translateArgs ( api : vsls . LiveShare , command : string , ...args : any [ ] ) : IMessageArgs {
108108 // Make sure to eliminate all .toJSON functions on our arguments. Otherwise they're stringified incorrectly
109109 for ( let a = 0 ; a <= args . length ; a += 1 ) {
110110 // Eliminate this on only object types (https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript)
@@ -130,12 +130,12 @@ export class PostOffice implements IAsyncDisposable {
130130 return { args : JSON . stringify ( copyArgs ) } ;
131131 }
132132
133- private escapeCommandName ( command : string ) : string {
133+ private escapeCommandName ( command : string ) : string {
134134 // Replace . with $ instead.
135135 return command . replace ( / \. / g, '$' ) ;
136136 }
137137
138- private unescapeCommandName ( command : string ) : string {
138+ private unescapeCommandName ( command : string ) : string {
139139 // Turn $ back into .
140140 return command . replace ( / \$ / g, '.' ) ;
141141 }
@@ -153,7 +153,7 @@ export class PostOffice implements IAsyncDisposable {
153153 }
154154 }
155155
156- private getCallback ( command : string ) : ( ( ...args : any [ ] ) => void ) | undefined {
156+ private getCallback ( command : string ) : ( ( ...args : any [ ] ) => void ) | undefined {
157157 let callback = this . commandMap . hasOwnProperty ( command ) ? this . commandMap [ command ] . callback : undefined ;
158158 if ( callback ) {
159159 // Bind the this arg if necessary
@@ -166,7 +166,7 @@ export class PostOffice implements IAsyncDisposable {
166166 return callback ;
167167 }
168168
169- private async startCommandServer ( ) : Promise < vsls . LiveShare | null > {
169+ private async startCommandServer ( ) : Promise < vsls . LiveShare | null > {
170170 const api = await this . liveShareApi . getApi ( ) ;
171171 if ( api !== null ) {
172172 api . onDidChangeSession ( ( ) => this . onChangeSession ( api ) . ignoreErrors ( ) ) ;
@@ -177,7 +177,7 @@ export class PostOffice implements IAsyncDisposable {
177177 return api ;
178178 }
179179
180- private async onChangeSession ( api : vsls . LiveShare ) : Promise < void > {
180+ private async onChangeSession ( api : vsls . LiveShare ) : Promise < void > {
181181 // Startup or shutdown our connection to the other side
182182 if ( api . session ) {
183183 if ( this . currentRole !== api . session . role ) {
@@ -209,7 +209,7 @@ export class PostOffice implements IAsyncDisposable {
209209 }
210210 }
211211
212- private async onChangePeers ( api : vsls . LiveShare ) : Promise < void > {
212+ private async onChangePeers ( api : vsls . LiveShare ) : Promise < void > {
213213 let newPeerCount = 0 ;
214214 if ( api . session ) {
215215 newPeerCount = api . peers . length ;
@@ -226,7 +226,7 @@ export class PostOffice implements IAsyncDisposable {
226226 if ( a . args . length > 0 ) {
227227 const jsonArray = JSON . parse ( a . args ) as JSONArray ;
228228 if ( jsonArray !== null && jsonArray . length >= 2 ) {
229- const firstArg = jsonArray [ 0 ] ; // More stupid hygiene problems.
229+ const firstArg = jsonArray [ 0 ] ! ; // More stupid hygiene problems.
230230 const command = firstArg !== null ? firstArg . toString ( ) : '' ;
231231
232232 // Args need to be translated from guest to host
0 commit comments