From 3ad77a5f9cda28d3cebdc413f652d4c883764150 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 15 Feb 2015 15:36:10 -0500 Subject: [PATCH] Show code and reason for non-1000 close events from server --- bin/wscat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/wscat b/bin/wscat index 093ac56..65f8786 100755 --- a/bin/wscat +++ b/bin/wscat @@ -205,8 +205,12 @@ if (program.listen && program.connect) { ws.send(data, { mask: true }); wsConsole.prompt(); }); - }).on('close', function close() { - wsConsole.print('disconnected', Console.Colors.Green); + }).on('close', function close(code, description) { + var msg = 'disconnected'; + if (code != 1000) { + msg += ' with error ' + code + (description ? ': ' + description : ''); + } + wsConsole.print(msg, Console.Colors.Green); wsConsole.clear(); process.exit(); }).on('error', function error(code, description) {