rename params to args
This commit is contained in:
parent
0f57e8ffcb
commit
bd0e0d8fec
@ -39,7 +39,7 @@ type Message struct {
|
|||||||
Type MsgType `json:"type"`
|
Type MsgType `json:"type"`
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
Params Vals `json:"params"`
|
Args Vals `json:"args"`
|
||||||
Result Vals `json:"result"`
|
Result Vals `json:"result"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
@ -118,8 +118,8 @@ func (ipc *ipcCommon) handleCall(msg Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
argsCount := method.Type().NumIn()
|
argsCount := method.Type().NumIn()
|
||||||
if len(msg.Params) != argsCount {
|
if len(msg.Args) != argsCount {
|
||||||
ipc.sendResponse(msg.Id, nil, fmt.Errorf("args count mismatch: expected %d, got %d", argsCount, len(msg.Params)))
|
ipc.sendResponse(msg.Id, nil, fmt.Errorf("args count mismatch: expected %d, got %d", argsCount, len(msg.Args)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ func (ipc *ipcCommon) Call(method string, params ...any) (Vals, error) {
|
|||||||
Type: MsgCall,
|
Type: MsgCall,
|
||||||
Id: id,
|
Id: id,
|
||||||
Method: method,
|
Method: method,
|
||||||
Params: params,
|
Args: params,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ipc.sendMsg(msg); err != nil {
|
if err := ipc.sendMsg(msg); err != nil {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ interface CallMessage {
|
|||||||
type: MsgType.Call,
|
type: MsgType.Call,
|
||||||
id: number,
|
id: number,
|
||||||
method: string;
|
method: string;
|
||||||
params: Vals;
|
args: Vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ResponseMessage {
|
interface ResponseMessage {
|
||||||
@ -129,18 +129,18 @@ abstract class IPCCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const argsCount = method.length;
|
const argsCount = method.length;
|
||||||
if (msg.params.length !== argsCount) {
|
if (msg.args.length !== argsCount) {
|
||||||
this.sendMsg({
|
this.sendMsg({
|
||||||
type: MsgType.Response,
|
type: MsgType.Response,
|
||||||
id: msg.id,
|
id: msg.id,
|
||||||
error: `argument count mismatch: expected ${ argsCount }, got ${ msg.params.length }`
|
error: `argument count mismatch: expected ${ argsCount }, got ${ msg.args.length }`
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.processingCalls++;
|
this.processingCalls++;
|
||||||
let result = method.apply(endpoint, msg.params);
|
let result = method.apply(endpoint, msg.args);
|
||||||
if (result instanceof Promise) {
|
if (result instanceof Promise) {
|
||||||
result = await result;
|
result = await result;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ abstract class IPCCommon {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
this.sendMsg({type: MsgType.Call, id, method, params});
|
this.sendMsg({type: MsgType.Call, id, method, args: params});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
delete this.pendingCalls[id];
|
delete this.pendingCalls[id];
|
||||||
reject(new Error(`send call: ${ e }`));
|
reject(new Error(`send call: ${ e }`));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user