branch: externals/websocket
commit d46cacb8b1d2c8b8a97c4d606bad43a87a54d1c5
Author: Andrew Hyatt <[email protected]>
Commit: Andrew Hyatt <[email protected]>
Add back in calling of websocket-close, this time more safely.
This needs to be done because when the connection is suddently killed,
the websocket would otherwise not be notified of being closed.
---
websocket.el | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/websocket.el b/websocket.el
index b1ce52e12c..564e04178a 100644
--- a/websocket.el
+++ b/websocket.el
@@ -689,7 +689,11 @@ describing the problem with the frame.
conn
(lambda (process change)
(let ((websocket (process-get process :websocket)))
- (websocket-debug websocket "State change to %s" change))))
+ (websocket-debug websocket "State change to %s" change)
+ (when (and
+ (member (process-status process) '(closed failed exit signal))
+ (not (eq 'closed (websocket-ready-state websocket))))
+ (websocket-try-callback 'websocket-on-close 'on-close websocket)))))
(set-process-query-on-exit-flag conn nil)
(process-send-string conn
(format "GET %s HTTP/1.1\r\n"
@@ -843,7 +847,11 @@ connection, which should be kept in order to pass to
(set-process-sentinel client
(lambda (process change)
(let ((websocket (process-get process :websocket)))
- (websocket-debug websocket "State change to %s" change))))))
+ (websocket-debug websocket "State change to %s" change)
+ (when (and
+ (member (process-status process) '(closed failed exit signal))
+ (not (eq 'closed (websocket-ready-state websocket))))
+ (websocket-try-callback 'websocket-on-close 'on-close
websocket)))))))
(defun websocket-create-headers (url key protocol extensions)
"Create connections headers for the given URL, KEY, PROTOCOL and EXTENSIONS.