branch: externals/websocket
commit 2bfc3036f6d5a9d5fe65480b85042dd03cec0f7a
Author: Andrew Hyatt <[email protected]>
Commit: Andrew Hyatt <[email protected]>
Handle on-close for all varieties of websocket closings.
This brings the actual behavior in line with what the docs say it does.
---
websocket.el | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/websocket.el b/websocket.el
index b1d8e6fe5e..b1ce52e12c 100644
--- a/websocket.el
+++ b/websocket.el
@@ -550,6 +550,7 @@ connecting or open."
(defun websocket-close (websocket)
"Close WEBSOCKET and erase all the old websocket data."
(websocket-debug websocket "Closing websocket")
+ (websocket-try-callback 'websocket-on-close 'on-close websocket)
(when (websocket-openp websocket)
(websocket-send websocket
(make-websocket-frame :opcode 'close
@@ -688,10 +689,7 @@ describing the problem with the frame.
conn
(lambda (process change)
(let ((websocket (process-get process :websocket)))
- (websocket-debug websocket
- "State change to %s" change)
- (unless (eq 'closed (websocket-ready-state websocket))
- (websocket-try-callback 'websocket-on-close 'on-close websocket)))))
+ (websocket-debug websocket "State change to %s" change))))
(set-process-query-on-exit-flag conn nil)
(process-send-string conn
(format "GET %s HTTP/1.1\r\n"
@@ -845,11 +843,7 @@ 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)
- (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)))))))
+ (websocket-debug websocket "State change to %s" change))))))
(defun websocket-create-headers (url key protocol extensions)
"Create connections headers for the given URL, KEY, PROTOCOL and EXTENSIONS.