@@ -41,7 +41,7 @@ class RPCBaseClient extends node_events_1.EventEmitter {
41
41
this . _lastPingTime = 0 ;
42
42
this . _closePromise = undefined ;
43
43
this . _protocolOptions = [ ] ;
44
- this . _protocol = undefined ;
44
+ this . _protocol = '' ;
45
45
this . _strictProtocols = [ ] ;
46
46
this . _strictValidators = new Map ( ) ;
47
47
this . _pendingCalls = new Map ( ) ;
@@ -77,6 +77,9 @@ class RPCBaseClient extends node_events_1.EventEmitter {
77
77
get state ( ) {
78
78
return this . _state ;
79
79
}
80
+ isProtocol ( protocol ) {
81
+ return this . _protocol === protocol ;
82
+ }
80
83
reconfigure ( options ) {
81
84
var _a ;
82
85
const newOpts = Object . assign ( this . _options , options ) ;
@@ -192,7 +195,7 @@ class RPCBaseClient extends node_events_1.EventEmitter {
192
195
this . _wildcardHandler = undefined ;
193
196
this . _handlers . clear ( ) ;
194
197
}
195
- async call ( method , params = { } , options = { } ) {
198
+ async call ( method , params , options = { } ) {
196
199
return await this . _callQueue . push ( this . _call . bind ( this , method , params , options ) ) ;
197
200
}
198
201
async _call ( method , params , options = { } ) {
@@ -201,18 +204,20 @@ class RPCBaseClient extends node_events_1.EventEmitter {
201
204
if ( [ StateEnum . CLOSED , StateEnum . CLOSING ] . includes ( this . _state ) ) {
202
205
throw Error ( `Cannot make call while socket not open` ) ;
203
206
}
207
+ const methodName = method ;
208
+ const paramsObj = params ;
204
209
const msgId = ( 0 , node_crypto_1 . randomUUID ) ( ) ;
205
- const payload = [ MsgType . CALL , msgId , method , params ] ;
210
+ const payload = [ MsgType . CALL , msgId , methodName , paramsObj ] ;
206
211
if ( typeof this . _protocol === 'string' && this . _strictProtocols . includes ( this . _protocol ) ) {
207
212
const validator = this . _strictValidators . get ( this . _protocol ) ;
208
213
try {
209
- validator . validate ( `urn:${ method } .req` , params ) ;
214
+ validator . validate ( `urn:${ methodName } .req` , paramsObj ) ;
210
215
}
211
216
catch ( error ) {
212
217
this . emit ( 'strictValidationFailure' , {
213
218
messageId : msgId ,
214
- method,
215
- params,
219
+ method : methodName ,
220
+ params : paramsObj ,
216
221
result : null ,
217
222
error,
218
223
outbound : true ,
@@ -223,8 +228,8 @@ class RPCBaseClient extends node_events_1.EventEmitter {
223
228
}
224
229
const pendingCall = {
225
230
msgId,
226
- method,
227
- params
231
+ method : methodName ,
232
+ params : paramsObj
228
233
} ;
229
234
if ( ! options . noReply ) {
230
235
const timeoutAc = new AbortController ( ) ;
@@ -275,8 +280,8 @@ class RPCBaseClient extends node_events_1.EventEmitter {
275
280
this . emit ( 'callResult' , {
276
281
outbound : true ,
277
282
messageId : msgId ,
278
- method,
279
- params,
283
+ method : methodName ,
284
+ params : paramsObj ,
280
285
result,
281
286
} ) ;
282
287
return result ;
@@ -285,8 +290,8 @@ class RPCBaseClient extends node_events_1.EventEmitter {
285
290
this . emit ( 'callError' , {
286
291
outbound : true ,
287
292
messageId : msgId ,
288
- method,
289
- params,
293
+ method : methodName ,
294
+ params : paramsObj ,
290
295
error : err ,
291
296
} ) ;
292
297
throw err ;
0 commit comments