mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 21:52:30 +01:00
Merge pull request #4044 from Hoekstraa/rfa-type-fix
RFA: Fix type of RFAMessages with non-String results
This commit is contained in:
commit
554f6d15d8
@ -1,14 +1,12 @@
|
|||||||
export class RFAMessage {
|
export class RFAMessage {
|
||||||
jsonrpc = "2.0"; // Transmits version of JSON-RPC. Compliance maybe allows some funky interaction with external tools?
|
jsonrpc = "2.0"; // Transmits version of JSON-RPC. Compliance maybe allows some funky interaction with external tools?
|
||||||
public method?: string; // Is defined when it's a request/notification, otherwise undefined
|
public method?: string; // Is defined when it's a request/notification, otherwise undefined
|
||||||
public result?: string | number; // Is defined when it's a response, otherwise undefined
|
public result?: ResultType; // Is defined when it's a response, otherwise undefined
|
||||||
public params?: FileMetadata; // Optional parameters to method
|
public params?: FileMetadata; // Optional parameters to method
|
||||||
public error?: string; // Only defined on error
|
public error?: string; // Only defined on error
|
||||||
public id?: number; // ID to keep track of request -> response interaction, undefined with notifications, defined with request/response
|
public id?: number; // ID to keep track of request -> response interaction, undefined with notifications, defined with request/response
|
||||||
|
|
||||||
constructor(
|
constructor(obj: { method?: string; result?: ResultType; params?: FileMetadata; error?: string; id?: number } = {}) {
|
||||||
obj: { method?: string; result?: string | number; params?: FileMetadata; error?: string; id?: number } = {},
|
|
||||||
) {
|
|
||||||
this.method = obj.method;
|
this.method = obj.method;
|
||||||
this.result = obj.result;
|
this.result = obj.result;
|
||||||
this.params = obj.params;
|
this.params = obj.params;
|
||||||
@ -17,6 +15,7 @@ export class RFAMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResultType = string | number | Array<string> | Array<FileContent>;
|
||||||
type FileMetadata = FileData | FileContent | FileLocation | FileServer;
|
type FileMetadata = FileData | FileContent | FileLocation | FileServer;
|
||||||
|
|
||||||
export interface FileData {
|
export interface FileData {
|
||||||
|
@ -93,7 +93,7 @@ export const RFARequestHandler: Record<string, (message: RFAMessage) => void | R
|
|||||||
...server.scripts.map((scr): string => scr.filename),
|
...server.scripts.map((scr): string => scr.filename),
|
||||||
];
|
];
|
||||||
|
|
||||||
return new RFAMessage({ result: JSON.stringify(fileNameList), id: msg.id });
|
return new RFAMessage({ result: fileNameList, id: msg.id });
|
||||||
},
|
},
|
||||||
|
|
||||||
getAllFiles: function (msg: RFAMessage): RFAMessage {
|
getAllFiles: function (msg: RFAMessage): RFAMessage {
|
||||||
@ -111,7 +111,7 @@ export const RFARequestHandler: Record<string, (message: RFAMessage) => void | R
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
return new RFAMessage({ result: JSON.stringify(fileList), id: msg.id });
|
return new RFAMessage({ result: fileList, id: msg.id });
|
||||||
},
|
},
|
||||||
|
|
||||||
calculateRam: function (msg: RFAMessage): RFAMessage {
|
calculateRam: function (msg: RFAMessage): RFAMessage {
|
||||||
|
Loading…
Reference in New Issue
Block a user