Browse Source

Add elisp and js support for disconnecting from the server.

The motivating use case is a nodejs server that wants to shut down but
blocks until the debugger disconnects.  This situation arises often
when a developer is using a tool like nodemon that automatically
restarts the server on every source file change.
master
Trevor Murphy 9 months ago
committed by Nicolas Petton
parent
commit
0535461fe8
3 changed files with 31 additions and 0 deletions
  1. +8
    -0
      indium-client.el
  2. +12
    -0
      server/README.md
  3. +11
    -0
      server/server/connection.js

+ 8
- 0
indium-client.el View File

@ -149,6 +149,14 @@ Once the client is connected, run the hook `indium-client-connected-hook'."
(lambda (&rest _)
(run-hooks 'indium-client-connected-hook))))
(defun indium-client-disconnect (&optional callback)
"Disconnect from the runtime, but do not stop the indium process.
When non-nil, evaluate CALLBACK with the result."
(indium-client-send `((type . "connection")
(payload . ((action . "disconnect"))))
callback))
(defun indium-client-evaluate (expression &optional frame callback)
"Evaluate EXPRESSION in the context of FRAME.


+ 12
- 0
server/README.md View File

@ -116,6 +116,18 @@ Array of configurations.
No payload.
#### disconnect
*Request payload:*
| Key | Type or value | Description |
|:-------|:---------------|:------------|
| action | `"disconnect"` | Action type |
*Successful response payload:*
No payload.
#### close
*Request payload:*


+ 11
- 0
server/server/connection.js View File

@ -5,6 +5,8 @@ const connection = (data = {}, { success, error, stop }) => {
switch(data.action) {
case "connect":
return connect(data, { success, error });
case "disconnect":
return disconnect({ success, error });
case "close":
return stop();
default:
@ -61,4 +63,13 @@ const connectToNode = async (options = {}, { success, error }) => {
success("Connected to Node!");
};
const disconnect = async ({ success, error }) => {
try {
await adapter.disconnect();
} catch(e) {
return error(e.message);
}
success("Disconnected");
};
module.exports = connection;

Loading…
Cancel
Save