html: implement flow control for xterm

https://xtermjs.org/docs/guides/flowcontrol/#flow-control-over-websockets
This commit is contained in:
Shuanglei Tao
2020-12-27 19:33:28 +08:00
parent 61a9bcd810
commit 4ab5479a83
5 changed files with 628 additions and 544 deletions

1096
src/html.h

File diff suppressed because it is too large Load Diff

View File

@@ -383,6 +383,18 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user,
}
}
} break;
case PAUSE:
if (proc->state == STATE_INIT) {
uv_read_stop((uv_stream_t *)&proc->pipe);
proc->state = STATE_PAUSE;
}
break;
case RESUME:
if (proc->state == STATE_PAUSE) {
uv_read_start((uv_stream_t *)&proc->pipe, alloc_cb, read_cb);
proc->state = STATE_INIT;
}
break;
case JSON_DATA:
if (proc->pid > 0) break;
if (server->credential != NULL) {

View File

@@ -6,6 +6,8 @@
// client message
#define INPUT '0'
#define RESIZE_TERMINAL '1'
#define PAUSE '2'
#define RESUME '3'
#define JSON_DATA '{'
// server message
@@ -26,7 +28,7 @@ extern struct lws_context *context;
extern struct server *server;
extern struct endpoints endpoints;
typedef enum { STATE_INIT, STATE_KILL, STATE_EXIT } proc_state;
typedef enum { STATE_INIT, STATE_PAUSE, STATE_KILL, STATE_EXIT } proc_state;
struct pss_http {
char path[128];