@@ -37,15 +37,15 @@ IncomingMessageTypes[OpCode.Identified]
3737export abstract class BaseOBSWebSocket extends EventEmitter < MapValueToArgsArray < EventTypes > > {
3838protected static requestCounter = 0 ;
3939
40+ protected static generateMessageId ( ) : string {
41+ return String ( BaseOBSWebSocket . requestCounter ++ ) ;
42+ }
43+
4044protected _identified = false ;
4145protected internalListeners = new EventEmitter ( ) ;
4246protected socket ?: WebSocket ;
4347protected abstract protocol : string ;
4448
45- protected static generateMessageId ( ) : string {
46- return String ( BaseOBSWebSocket . requestCounter ++ ) ;
47- }
48-
4949public get identified ( ) {
5050return this . _identified ;
5151}
@@ -68,15 +68,15 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
6868}
6969
7070try {
71- const ConnectionClosedPromise = this . internalEventPromise < CloseEvent > ( 'ConnectionClosed' ) ;
71+ const connectionClosedPromise = this . internalEventPromise < CloseEvent > ( 'ConnectionClosed' ) ;
7272
7373return await Promise . race ( [
7474( async ( ) => {
7575const hello = await this . createConnection ( url ) ;
7676this . emit ( 'Hello' , hello ) ;
7777return this . identify ( hello , password , identificationParams ) ;
7878} ) ( ) ,
79- ConnectionClosedPromise . then ( e => {
79+ connectionClosedPromise . then ( e => {
8080throw new OBSWebSocketError ( e . code , e . reason ) ;
8181} ) ,
8282] ) ;
@@ -94,9 +94,9 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
9494return ;
9595}
9696
97- const ConnectionClosedPromise = this . internalEventPromise ( 'ConnectionClosed' ) ;
97+ const connectionClosedPromise = this . internalEventPromise ( 'ConnectionClosed' ) ;
9898this . socket . close ( ) ;
99- await ConnectionClosedPromise ;
99+ await connectionClosedPromise ;
100100}
101101
102102/**
@@ -106,9 +106,9 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
106106 * @returns Identified message data
107107 */
108108async reidentify ( data : OutgoingMessageTypes [ OpCode . Reidentify ] ) {
109- const IdentifiedPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Identified ] > ( `op:${ OpCode . Identified } ` ) ;
109+ const identifiedPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Identified ] > ( `op:${ OpCode . Identified } ` ) ;
110110await this . message ( OpCode . Reidentify , data ) ;
111- return IdentifiedPromise ;
111+ return identifiedPromise ;
112112}
113113
114114/**
@@ -119,13 +119,13 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
119119 */
120120async call < Type extends keyof OBSRequestTypes > ( requestType : Type , requestData : OBSRequestTypes [ Type ] ) : Promise < OBSResponseTypes [ Type ] > {
121121const requestId = BaseOBSWebSocket . generateMessageId ( ) ;
122- const ResponsePromise = this . internalEventPromise < ResponseMessage < Type > > ( `res:${ requestId } ` ) ;
122+ const responsePromise = this . internalEventPromise < ResponseMessage < Type > > ( `res:${ requestId } ` ) ;
123123await this . message ( OpCode . Request , {
124124requestId,
125125requestType,
126126requestData,
127127} as RequestMessage < Type > ) ;
128- const { requestStatus, responseData} = await ResponsePromise ;
128+ const { requestStatus, responseData} = await responsePromise ;
129129
130130if ( ! requestStatus . result ) {
131131throw new OBSWebSocketError ( requestStatus . code , requestStatus . comment ) ;
@@ -159,16 +159,16 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
159159 * @param url Websocket address
160160 */
161161protected async createConnection ( url : string ) {
162- const ConnectionOpenedPromise = this . internalEventPromise ( 'ConnectionOpened' ) ;
163- const HelloPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Hello ] > ( `op:${ OpCode . Hello } ` ) ;
162+ const connectionOpenedPromise = this . internalEventPromise ( 'ConnectionOpened' ) ;
163+ const helloPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Hello ] > ( `op:${ OpCode . Hello } ` ) ;
164164
165165this . socket = new WebSocketIpml ( url , this . protocol ) as unknown as WebSocket ;
166166this . socket . onopen = this . onOpen . bind ( this ) ;
167167this . socket . onmessage = this . onMessage . bind ( this ) ;
168168this . socket . onerror = this . onError . bind ( this ) ;
169169this . socket . onclose = this . onClose . bind ( this ) ;
170170
171- await ConnectionOpenedPromise ;
171+ await connectionOpenedPromise ;
172172const protocol = this . socket ?. protocol ;
173173if ( ! protocol ) {
174174throw new OBSWebSocketError ( - 1 , 'Missing socket protocol (server must be v5 or newer)' ) ;
@@ -178,7 +178,7 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
178178throw new OBSWebSocketError ( - 2 , `Unknown socket protocol (${ protocol } )` ) ;
179179}
180180
181- return HelloPromise ;
181+ return helloPromise ;
182182}
183183
184184/**
@@ -208,9 +208,9 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
208208data . authentication = authenticationHashing ( authentication . salt , authentication . challenge , password ) ;
209209}
210210
211- const IdentifiedPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Identified ] > ( `op:${ OpCode . Identified } ` ) ;
211+ const identifiedPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Identified ] > ( `op:${ OpCode . Identified } ` ) ;
212212await this . message ( OpCode . Identify , data ) ;
213- const identified = await IdentifiedPromise ;
213+ const identified = await identifiedPromise ;
214214this . _identified = true ;
215215this . emit ( 'Identified' , identified ) ;
216216
0 commit comments