* Call remote function. throw * @param method method name * @param args arguments passed to method
(method: string, ...args: Args)
| 53 | * @param args arguments passed to method |
| 54 | */ |
| 55 | protected async Call<Args extends any[], Ret>(method: string, ...args: Args): Promise<Ret> { |
| 56 | return new Promise((resolve, reject) => { |
| 57 | const req: Request = { method, callId: this.GetCallId(), args }; |
| 58 | |
| 59 | this.socket.emit(this.RPC, req); |
| 60 | |
| 61 | const timeoutTimer = setTimeout(() => { |
| 62 | this.RemovePendingRequest(req.callId); |
| 63 | reject(new Error(`Method call '${method}' timed out.`)); |
| 64 | }, this.responseTimeout); |
| 65 | |
| 66 | this.pendingRequests.push({ callId: req.callId, timeoutTimer, fn: resolve }); |
| 67 | }); |
| 68 | } |
| 69 | } |
no test coverage detected