rename params to args

This commit is contained in:
Egor Aristov 2025-11-15 17:40:33 +03:00
parent 0f57e8ffcb
commit bd0e0d8fec
Signed by: egor3f
GPG Key ID: 40482A264AAEC85F
2 changed files with 9 additions and 9 deletions

View File

@ -39,7 +39,7 @@ type Message struct {
Type MsgType `json:"type"`
Id int64 `json:"id"`
Method string `json:"method"`
Params Vals `json:"params"`
Args Vals `json:"args"`
Result Vals `json:"result"`
Error string `json:"error"`
}
@ -118,8 +118,8 @@ func (ipc *ipcCommon) handleCall(msg Message) {
}
argsCount := method.Type().NumIn()
if len(msg.Params) != argsCount {
ipc.sendResponse(msg.Id, nil, fmt.Errorf("args count mismatch: expected %d, got %d", argsCount, len(msg.Params)))
if len(msg.Args) != argsCount {
ipc.sendResponse(msg.Id, nil, fmt.Errorf("args count mismatch: expected %d, got %d", argsCount, len(msg.Args)))
return
}
@ -221,7 +221,7 @@ func (ipc *ipcCommon) Call(method string, params ...any) (Vals, error) {
Type: MsgCall,
Id: id,
Method: method,
Params: params,
Args: params,
}
if err := ipc.sendMsg(msg); err != nil {

View File

@ -20,7 +20,7 @@ interface CallMessage {
type: MsgType.Call,
id: number,
method: string;
params: Vals;
args: Vals;
}
interface ResponseMessage {
@ -129,18 +129,18 @@ abstract class IPCCommon {
}
const argsCount = method.length;
if (msg.params.length !== argsCount) {
if (msg.args.length !== argsCount) {
this.sendMsg({
type: MsgType.Response,
id: msg.id,
error: `argument count mismatch: expected ${ argsCount }, got ${ msg.params.length }`
error: `argument count mismatch: expected ${ argsCount }, got ${ msg.args.length }`
});
return;
}
try {
this.processingCalls++;
let result = method.apply(endpoint, msg.params);
let result = method.apply(endpoint, msg.args);
if (result instanceof Promise) {
result = await result;
}
@ -192,7 +192,7 @@ abstract class IPCCommon {
}
};
try {
this.sendMsg({type: MsgType.Call, id, method, params});
this.sendMsg({type: MsgType.Call, id, method, args: params});
} catch (e) {
delete this.pendingCalls[id];
reject(new Error(`send call: ${ e }`));