RFA: add ping function to respond to JSON-RPC pings - #2298
Conversation
| }, | ||
|
|
||
| ping: function (msg: RFAMessage): RFAMessage { | ||
| return new RFAMessage({ result: {}, id: msg.id }); |
There was a problem hiding this comment.
| return new RFAMessage({ result: {}, id: msg.id }); | |
| return new RFAMessage({ result: null, id: msg.id }); |
I think null makes more sense for an empty response? And it also makes for a more straightforward type in ResultType.
|
Why do we need this API? RFA is built on top of WebSocket, and ping-pong is defined in the protocol. All (good) libraries support it.
If the RFA tool wants to maintain the connection via a heartbeat, it should use the built-in ping-pong mechanic of WebSocket. |
|
Ah, I didn't realize we could already accomplish this at a lower protocol layer. |
|
We're not currently using a websocket library in the code. Is that something that we want to adopt? Because otherwise, there's no way to send a ping websocket frame via the native javascript WebSocket API. |
|
I've added the websocket ping functionality as a pull request at bitburner-official/bitburner-filesync#36 . Closing this request. |
PR includes no ns API changes but the documentation for RFA methods has been updated as part of this pull request.
npm run format and npm run lint have been run.
Has been tested both with a server with and without ping functionality and works fine.
Corresponds to bitburner-official/bitburner-filesync#35