|
@ -123,8 +123,8 @@ export abstract class IpcClientService<M extends Microservice = Microservice> ex |
|
|
/** |
|
|
/** |
|
|
* Perform a general request and wait for a response |
|
|
* Perform a general request and wait for a response |
|
|
*/ |
|
|
*/ |
|
|
protected async request<T = any>(method: string, data?: T, timeout: number|null = null) { |
|
|
|
|
|
return new Promise<IIpcResponse<T>>((resolve, reject) => { |
|
|
|
|
|
|
|
|
protected async request<T = any>(method: string, data?: any, timeout: number|null = null) { |
|
|
|
|
|
return new Promise<T>((resolve, reject) => { |
|
|
// If the client is not connected to a server, reject immediately
|
|
|
// If the client is not connected to a server, reject immediately
|
|
|
if (!this.__isConnected || this.__socket === null) { |
|
|
if (!this.__isConnected || this.__socket === null) { |
|
|
reject(new IpcConnectionError("Not connected")); |
|
|
reject(new IpcConnectionError("Not connected")); |
|
@ -146,10 +146,10 @@ export abstract class IpcClientService<M extends Microservice = Microservice> ex |
|
|
let respond = (response: IIpcResponse<T>) => { |
|
|
let respond = (response: IIpcResponse<T>) => { |
|
|
cleanUp(); |
|
|
cleanUp(); |
|
|
if (response.error !== undefined) { |
|
|
if (response.error !== undefined) { |
|
|
reject(new IpcResponseError<T>(response.error, response.data)); |
|
|
|
|
|
|
|
|
reject(new IpcResponseError<T>(response.error)); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
resolve(response); |
|
|
|
|
|
|
|
|
resolve(response.data); |
|
|
}; |
|
|
}; |
|
|
// Abort the request
|
|
|
// Abort the request
|
|
|
let abort = (error: IpcError) => { |
|
|
let abort = (error: IpcError) => { |
|
|