@@ -37,15 +37,15 @@ IncomingMessageTypes[OpCode.Identified]
37
37
export abstract class BaseOBSWebSocket extends EventEmitter < MapValueToArgsArray < EventTypes > > {
38
38
protected static requestCounter = 0 ;
39
39
40
+ protected static generateMessageId ( ) : string {
41
+ return String ( BaseOBSWebSocket . requestCounter ++ ) ;
42
+ }
43
+
40
44
protected _identified = false ;
41
45
protected internalListeners = new EventEmitter ( ) ;
42
46
protected socket ?: WebSocket ;
43
47
protected abstract protocol : string ;
44
48
45
- protected static generateMessageId ( ) : string {
46
- return String ( BaseOBSWebSocket . requestCounter ++ ) ;
47
- }
48
-
49
49
public get identified ( ) {
50
50
return this . _identified ;
51
51
}
@@ -68,15 +68,15 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
68
68
}
69
69
70
70
try {
71
- const ConnectionClosedPromise = this . internalEventPromise < CloseEvent > ( 'ConnectionClosed' ) ;
71
+ const connectionClosedPromise = this . internalEventPromise < CloseEvent > ( 'ConnectionClosed' ) ;
72
72
73
73
return await Promise . race ( [
74
74
( async ( ) => {
75
75
const hello = await this . createConnection ( url ) ;
76
76
this . emit ( 'Hello' , hello ) ;
77
77
return this . identify ( hello , password , identificationParams ) ;
78
78
} ) ( ) ,
79
- ConnectionClosedPromise . then ( e => {
79
+ connectionClosedPromise . then ( e => {
80
80
throw new OBSWebSocketError ( e . code , e . reason ) ;
81
81
} ) ,
82
82
] ) ;
@@ -94,9 +94,9 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
94
94
return ;
95
95
}
96
96
97
- const ConnectionClosedPromise = this . internalEventPromise ( 'ConnectionClosed' ) ;
97
+ const connectionClosedPromise = this . internalEventPromise ( 'ConnectionClosed' ) ;
98
98
this . socket . close ( ) ;
99
- await ConnectionClosedPromise ;
99
+ await connectionClosedPromise ;
100
100
}
101
101
102
102
/**
@@ -106,9 +106,9 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
106
106
* @returns Identified message data
107
107
*/
108
108
async 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 } ` ) ;
110
110
await this . message ( OpCode . Reidentify , data ) ;
111
- return IdentifiedPromise ;
111
+ return identifiedPromise ;
112
112
}
113
113
114
114
/**
@@ -119,13 +119,13 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
119
119
*/
120
120
async call < Type extends keyof OBSRequestTypes > ( requestType : Type , requestData : OBSRequestTypes [ Type ] ) : Promise < OBSResponseTypes [ Type ] > {
121
121
const requestId = BaseOBSWebSocket . generateMessageId ( ) ;
122
- const ResponsePromise = this . internalEventPromise < ResponseMessage < Type > > ( `res:${ requestId } ` ) ;
122
+ const responsePromise = this . internalEventPromise < ResponseMessage < Type > > ( `res:${ requestId } ` ) ;
123
123
await this . message ( OpCode . Request , {
124
124
requestId,
125
125
requestType,
126
126
requestData,
127
127
} as RequestMessage < Type > ) ;
128
- const { requestStatus, responseData} = await ResponsePromise ;
128
+ const { requestStatus, responseData} = await responsePromise ;
129
129
130
130
if ( ! requestStatus . result ) {
131
131
throw new OBSWebSocketError ( requestStatus . code , requestStatus . comment ) ;
@@ -159,16 +159,16 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
159
159
* @param url Websocket address
160
160
*/
161
161
protected 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 } ` ) ;
164
164
165
165
this . socket = new WebSocketIpml ( url , this . protocol ) as unknown as WebSocket ;
166
166
this . socket . onopen = this . onOpen . bind ( this ) ;
167
167
this . socket . onmessage = this . onMessage . bind ( this ) ;
168
168
this . socket . onerror = this . onError . bind ( this ) ;
169
169
this . socket . onclose = this . onClose . bind ( this ) ;
170
170
171
- await ConnectionOpenedPromise ;
171
+ await connectionOpenedPromise ;
172
172
const protocol = this . socket ?. protocol ;
173
173
if ( ! protocol ) {
174
174
throw new OBSWebSocketError ( - 1 , 'Missing socket protocol (server must be v5 or newer)' ) ;
@@ -178,7 +178,7 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
178
178
throw new OBSWebSocketError ( - 2 , `Unknown socket protocol (${ protocol } )` ) ;
179
179
}
180
180
181
- return HelloPromise ;
181
+ return helloPromise ;
182
182
}
183
183
184
184
/**
@@ -208,9 +208,9 @@ export abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<
208
208
data . authentication = authenticationHashing ( authentication . salt , authentication . challenge , password ) ;
209
209
}
210
210
211
- const IdentifiedPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Identified ] > ( `op:${ OpCode . Identified } ` ) ;
211
+ const identifiedPromise = this . internalEventPromise < IncomingMessageTypes [ OpCode . Identified ] > ( `op:${ OpCode . Identified } ` ) ;
212
212
await this . message ( OpCode . Identify , data ) ;
213
- const identified = await IdentifiedPromise ;
213
+ const identified = await identifiedPromise ;
214
214
this . _identified = true ;
215
215
this . emit ( 'Identified' , identified ) ;
216
216
0 commit comments