Permalink
Browse files

Update websocket-close and test

  • Loading branch information...
1 parent 1081075 commit 33ff92c3d4c4066d284dc621b941c57281f8f3bd @ahyatt committed May 26, 2012
Showing with 17 additions and 1 deletion.
  1. +14 −0 websocket-test.el
  2. +3 −1 websocket.el
View
@@ -211,3 +211,17 @@
(websocket-encode-frame (make-websocket-frame :opcode opcode
:completep t))))))))
+(ert-deftest websocket-close ()
+ (let ((sent-frames))
+ (flet ((websocket-send (websocket frame) (push frame sent-frames))
+ (websocket-openp (websocket) t)
+ (kill-buffer (buffer))
+ (process-buffer (conn)))
+ (websocket-close (make-websocket :conn "fake-conn"
+ :filter t
+ :url t
+ :accept-string t
+ :close-callback t))
+ (should (equal sent-frames (list
+ (make-websocket-frame :opcode 'close
+ :completep t)))))))
View
@@ -382,7 +382,9 @@ If the frame is a close, we terminate the connection."
"Close the websocket and erase all the old websocket data."
(websocket-debug websocket "Closing websocket")
(when (websocket-openp websocket)
- (process-send-string (websocket-conn websocket) (unibyte-string ?\377?\0)))
+ (websocket-send websocket
+ (make-websocket-frame :opcode 'close
+ :completep t)))
(kill-buffer (process-buffer (websocket-conn websocket))))
(defun websocket-ensure-connected (websocket)

0 comments on commit 33ff92c

Please sign in to comment.