From 0a3bd83b19c218379232a910dcff6a51ceb732d2 Mon Sep 17 00:00:00 2001 From: Nicolas Viennot Date: Sat, 2 Jan 2016 11:03:04 -0500 Subject: [PATCH] Use a session termination message --- session.c | 4 ++++ tmate-encoder.c | 6 ++++++ tmate-protocol.h | 2 ++ tmate.h | 1 + 4 files changed, 13 insertions(+) diff --git a/session.c b/session.c index ab821a81..0fff9ef2 100644 --- a/session.c +++ b/session.c @@ -215,6 +215,10 @@ session_destroy(struct session *s) log_debug("session %s destroyed", s->name); +#ifdef TMATE + tmate_write_fin(); +#endif + RB_REMOVE(sessions, &sessions, s); notify_session_closed(s); diff --git a/tmate-encoder.c b/tmate-encoder.c index 8d47f2ef..ff6924da 100644 --- a/tmate-encoder.c +++ b/tmate-encoder.c @@ -224,3 +224,9 @@ void tmate_write_copy_mode(struct window_pane *wp, const char *str) pack(int, wp->id); pack(string, str); } + +void tmate_write_fin(void) +{ + pack(array, 1); + pack(int, TMATE_OUT_FIN); +} diff --git a/tmate-protocol.h b/tmate-protocol.h index 8611d9a7..45beaec6 100644 --- a/tmate-protocol.h +++ b/tmate-protocol.h @@ -48,6 +48,7 @@ enum tmate_daemon_out_msg_types { TMATE_OUT_STATUS, TMATE_OUT_SYNC_COPY_MODE, TMATE_OUT_WRITE_COPY_MODE, + TMATE_OUT_FIN, }; /* @@ -64,6 +65,7 @@ enum tmate_daemon_out_msg_types { [int: type, string: input_prompt, string: input_str]]) // Any of the array can be [] [TMATE_OUT_WRITE_COPY_MODE, int: pane_id, string: str] +[TMATE_OUT_FIN] */ enum tmate_daemon_in_msg_types { diff --git a/tmate.h b/tmate.h index 0474e081..2018bbc3 100644 --- a/tmate.h +++ b/tmate.h @@ -84,6 +84,7 @@ extern void tmate_failed_cmd(int client_id, const char *cause); extern void tmate_status(const char *left, const char *right); extern void tmate_sync_copy_mode(struct window_pane *wp); extern void tmate_write_copy_mode(struct window_pane *wp, const char *str); +extern void tmate_write_fin(void); /* tmate-decoder.c */