;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\207" [require bindat url-parse url-cookie seq] 2) #@68 compiler-macro for inlining `websocket-p'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-p (and (memq (type-of cl-x) cl-struct-websocket-tags) t)) nil] 9 (#$ . 198)]) (put 'websocket-p 'compiler-macro 'websocket-p--cmacro) #@13 (fn CL-X) (defalias 'websocket-p #[257 "\301!>\205 \302\207" [cl-struct-websocket-tags type-of t] 3 (#$ . 525)]) (byte-code "\300\301\302\303#\304\305\306\301#\207" [function-put websocket-p side-effect-free error-free put websocket cl-deftype-satisfies] 5) #@78 compiler-macro for inlining `websocket-ready-state'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-ready-state--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-ready-state (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 1))) nil] 9 (#$ . 794)]) (put 'websocket-ready-state 'compiler-macro 'websocket-ready-state--cmacro) #@66 Access slot "ready-state" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-ready-state #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 1] 5 (#$ . 1215)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-ready-state side-effect-free t] 4) #@78 compiler-macro for inlining `websocket-client-data'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-client-data--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-client-data (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 2))) nil] 9 (#$ . 1563)]) (put 'websocket-client-data 'compiler-macro 'websocket-client-data--cmacro) #@66 Access slot "client-data" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-client-data #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 2] 5 (#$ . 1985)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-client-data side-effect-free t] 4) #@74 compiler-macro for inlining `websocket-on-open'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-on-open--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-on-open (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 3))) nil] 9 (#$ . 2333)]) (put 'websocket-on-open 'compiler-macro 'websocket-on-open--cmacro) #@62 Access slot "on-open" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-on-open #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 3] 5 (#$ . 2735)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-on-open side-effect-free t] 4) #@77 compiler-macro for inlining `websocket-on-message'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-on-message--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-on-message (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 4))) nil] 9 (#$ . 3071)]) (put 'websocket-on-message 'compiler-macro 'websocket-on-message--cmacro) #@65 Access slot "on-message" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-on-message #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 4] 5 (#$ . 3488)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-on-message side-effect-free t] 4) #@75 compiler-macro for inlining `websocket-on-close'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-on-close--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-on-close (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 5))) nil] 9 (#$ . 3833)]) (put 'websocket-on-close 'compiler-macro 'websocket-on-close--cmacro) #@63 Access slot "on-close" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-on-close #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 5] 5 (#$ . 4240)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-on-close side-effect-free t] 4) #@75 compiler-macro for inlining `websocket-on-error'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-on-error--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-on-error (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 6))) nil] 9 (#$ . 4579)]) (put 'websocket-on-error 'compiler-macro 'websocket-on-error--cmacro) #@63 Access slot "on-error" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-on-error #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 6] 5 (#$ . 4986)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-on-error side-effect-free t] 4) #@87 compiler-macro for inlining `websocket-negotiated-protocols'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-negotiated-protocols--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-negotiated-protocols (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 7))) nil] 9 (#$ . 5325)]) (put 'websocket-negotiated-protocols 'compiler-macro 'websocket-negotiated-protocols--cmacro) #@75 Access slot "negotiated-protocols" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-negotiated-protocols #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 7] 5 (#$ . 5792)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-negotiated-protocols side-effect-free t] 4) #@88 compiler-macro for inlining `websocket-negotiated-extensions'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-negotiated-extensions--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-negotiated-extensions (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 8))) nil] 9 (#$ . 6167)]) (put 'websocket-negotiated-extensions 'compiler-macro 'websocket-negotiated-extensions--cmacro) #@76 Access slot "negotiated-extensions" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-negotiated-extensions #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 8] 5 (#$ . 6639)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-negotiated-extensions side-effect-free t] 4) #@75 compiler-macro for inlining `websocket-server-p'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-server-p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-server-p (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 9))) nil] 9 (#$ . 7017)]) (put 'websocket-server-p 'compiler-macro 'websocket-server-p--cmacro) #@63 Access slot "server-p" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-server-p #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 9] 5 (#$ . 7424)]) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put websocket-server-p side-effect-free t gv-expander #[514 "\300\301\302\"\207" [error "%s is a read-only slot" websocket-server-p] 5 "\n\n(fn CL-DO CL-X)"]] 5) #@70 compiler-macro for inlining `websocket-url'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-url--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-url (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 10))) nil] 9 (#$ . 7896)]) (put 'websocket-url 'compiler-macro 'websocket-url--cmacro) #@58 Access slot "url" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-url #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 10] 5 (#$ . 8279)]) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put websocket-url side-effect-free t gv-expander #[514 "\300\301\302\"\207" [error "%s is a read-only slot" websocket-url] 5 "\n\n(fn CL-DO CL-X)"]] 5) #@76 compiler-macro for inlining `websocket-protocols'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-protocols--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-protocols (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 11))) nil] 9 (#$ . 8732)]) (put 'websocket-protocols 'compiler-macro 'websocket-protocols--cmacro) #@64 Access slot "protocols" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-protocols #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 11] 5 (#$ . 9145)]) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put websocket-protocols side-effect-free t gv-expander #[514 "\300\301\302\"\207" [error "%s is a read-only slot" websocket-protocols] 5 "\n\n(fn CL-DO CL-X)"]] 5) #@77 compiler-macro for inlining `websocket-extensions'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-extensions--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-extensions (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 12))) nil] 9 (#$ . 9622)]) (put 'websocket-extensions 'compiler-macro 'websocket-extensions--cmacro) #@65 Access slot "extensions" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-extensions #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 12] 5 (#$ . 10040)]) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put websocket-extensions side-effect-free t gv-expander #[514 "\300\301\302\"\207" [error "%s is a read-only slot" websocket-extensions] 5 "\n\n(fn CL-DO CL-X)"]] 5) #@71 compiler-macro for inlining `websocket-conn'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-conn--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-conn (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 13))) nil] 9 (#$ . 10522)]) (put 'websocket-conn 'compiler-macro 'websocket-conn--cmacro) #@59 Access slot "conn" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-conn #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 13] 5 (#$ . 10911)]) (byte-code "\300\301\302\303#\300\301\304\305#\300\207" [function-put websocket-conn side-effect-free t gv-expander #[514 "\300\301\302\"\207" [error "%s is a read-only slot" websocket-conn] 5 "\n\n(fn CL-DO CL-X)"]] 5) #@78 compiler-macro for inlining `websocket-server-conn'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-server-conn--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-server-conn (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 14))) nil] 9 (#$ . 11369)]) (put 'websocket-server-conn 'compiler-macro 'websocket-server-conn--cmacro) #@66 Access slot "server-conn" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-server-conn #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 14] 5 (#$ . 11793)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-server-conn side-effect-free t] 4) #@80 compiler-macro for inlining `websocket-accept-string'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-accept-string--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-accept-string (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 15))) nil] 9 (#$ . 12143)]) (put 'websocket-accept-string 'compiler-macro 'websocket-accept-string--cmacro) #@68 Access slot "accept-string" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-accept-string #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 15] 5 (#$ . 12577)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-accept-string side-effect-free t] 4) #@81 compiler-macro for inlining `websocket-inflight-input'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-inflight-input--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-inflight-input (progn (or (websocket-p cl-x) (signal 'wrong-type-argument (list 'websocket cl-x))) (aref cl-x 16))) nil] 9 (#$ . 12933)]) (put 'websocket-inflight-input 'compiler-macro 'websocket-inflight-input--cmacro) #@69 Access slot "inflight-input" of `websocket' struct CL-X. (fn CL-X) (defalias 'websocket-inflight-input #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 16] 5 (#$ . 13372)]) (byte-code "\300\301\302\303#\304\305\306\"\207" [function-put websocket-inflight-input side-effect-free t defalias copy-websocket copy-sequence] 4) #@269 compiler-macro for inlining `websocket-inner-create'. (fn CL-WHOLE &cl-quote &key READY-STATE CLIENT-DATA ON-OPEN ON-MESSAGE ON-CLOSE ON-ERROR NEGOTIATED-PROTOCOLS NEGOTIATED-EXTENSIONS SERVER-P URL PROTOCOLS EXTENSIONS CONN SERVER-CONN ACCEPT-STRING INFLIGHT-INPUT) (defalias 'websocket-inner-create--cmacro #[385 "\300\301\"\206\302A@\300\303\"A@\300\304\"A@\300\305\"A@\300\306\"A@\300\307\"A@\300\310\"A@\300\311\"A@\300 \312\"A@\300\n\313\"\206G\314A@\300 \315\"A@\300\f\316\"A@\300 \317\"\206`\320A@\300\321\"A@\300\322\"A@\300\323\"A@\211\203\244\211@\324>\203\214\211AA\262\202y\325>A@\203\233\326\262\202y\327\330@\"\210\202y\210\331\332\333\326\326&\207" [plist-member :ready-state (nil 'connecting) :client-data :on-open :on-message :on-close :on-error :negotiated-protocols :negotiated-extensions :server-p :url (nil (cl-assert nil)) :protocols :extensions :conn (nil (cl-assert nil)) :server-conn :accept-string :inflight-input (:ready-state :client-data :on-open :on-message :on-close :on-error :negotiated-protocols :negotiated-extensions :server-p :url :protocols :extensions :conn :server-conn :accept-string :inflight-input :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:ready-state :client-data :on-open :on-message :on-close :on-error :negotiated-protocols :negotiated-extensions :server-p :url :protocols :extensions :conn :server-conn :accept-string :inflight-input)" cl--defsubst-expand (ready-state client-data on-open on-message on-close on-error negotiated-protocols negotiated-extensions server-p url protocols extensions conn server-conn accept-string inflight-input) (cl-block websocket-inner-create (record 'websocket ready-state client-data on-open on-message on-close on-error negotiated-protocols negotiated-extensions server-p url protocols extensions conn server-conn accept-string inflight-input))] 40 (#$ . 13780)]) (put 'websocket-inner-create 'compiler-macro 'websocket-inner-create--cmacro) #@241 Constructor for objects of type `websocket'. (fn &key READY-STATE CLIENT-DATA ON-OPEN ON-MESSAGE ON-CLOSE ON-ERROR NEGOTIATED-PROTOCOLS NEGOTIATED-EXTENSIONS SERVER-P URL PROTOCOLS EXTENSIONS CONN SERVER-CONN ACCEPT-STRING INFLIGHT-INPUT) (defalias 'websocket-inner-create #[128 "\300\301\"\206\302A@\300\303\"A@\300\304\"A@\300\305\"A@\300\306\"A@\300\307\"A@\300\310\"A@\300\311\"A@\300 \312\"A@\300\n\313\"\206I\314\211DA@\300 \315\"A@\300\f\316\"A@\300 \317\"\206d\314\211DA@\300\320\"A@\300\321\"A@\300\322\"A@\211\203\250\211@\323>\203\220\211AA\262\202}\324>A@\203\237\314\262\202}\325\326@\"\210\202}\210\327\330&\207" [plist-member :ready-state (nil connecting) :client-data :on-open :on-message :on-close :on-error :negotiated-protocols :negotiated-extensions :server-p :url nil :protocols :extensions :conn :server-conn :accept-string :inflight-input (:ready-state :client-data :on-open :on-message :on-close :on-error :negotiated-protocols :negotiated-extensions :server-p :url :protocols :extensions :conn :server-conn :accept-string :inflight-input :allow-other-keys) :allow-other-keys error "Keyword argument %s not one of (:ready-state :client-data :on-open :on-message :on-close :on-error :negotiated-protocols :negotiated-extensions :server-p :url :protocols :extensions :conn :server-conn :accept-string :inflight-input)" record websocket] 35 (#$ . 15827)]) (cl-struct-define 'websocket "A websocket structure.\nThis follows the W3C Websocket API, except translated to elisp\nidioms. The API is implemented in both the websocket struct and\nadditional methods. Due to how defstruct slots are accessed, all\nAPI methods are prefixed with \"websocket-\" and take a websocket\nas an argument, so the distrinction between the struct API and\nthe additional helper APIs are not visible to the caller.\n\nA websocket struct is created with `websocket-open'.\n\n`ready-state' contains one of `connecting', `open', or\n`closed', depending on the state of the websocket.\n\nThe W3C API \"bufferedAmount\" call is not currently implemented,\nsince there is no elisp API to get the buffered amount from the\nsubprocess. There may, in fact, be output data buffered,\nhowever, when the `on-message' or `on-close' callbacks are\ncalled.\n\n`on-open', `on-message', `on-close', and `on-error' are described\nin `websocket-open'.\n\nThe `negotiated-extensions' slot lists the extensions accepted by\nboth the client and server, and `negotiated-protocols' does the\nsame for the protocols." 'cl-structure-object 'record nil '((cl-tag-slot) (ready-state 'connecting) (client-data) (on-open) (on-message) (on-close) (on-error) (negotiated-protocols) (negotiated-extensions) (server-p nil :read-only t) (url (cl-assert nil) :read-only t) (protocols nil :read-only t) (extensions nil :read-only t) (conn (cl-assert nil) :read-only t) (server-conn) (accept-string) (inflight-input nil)) 'cl-struct-websocket-tags 'websocket t) #@50 Version numbers of this version of websocket.el. (defvar websocket-version "1.12" (#$ . 18833)) #@144 Set to true to output debugging info to a per-websocket buffer. The buffer is ` *websocket URL debug*' where URL is the URL of the connection. (defvar websocket-debug nil (#$ . 18936)) #@82 The websocket GUID as defined in RFC 6455. Do not change unless the RFC changes. (defconst websocket-guid "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (#$ . 19127)) #@257 If true, when an error happens in a client callback, invoke the debugger. Having this on can cause issues with missing frames if the debugger is exited by quitting instead of continuing, so it's best to have this set to nil unless it is especially needed. (defvar websocket-callback-debug-on-error nil (#$ . 19293)) #@98 Document FUNCTION with DOCSTRING. Use this for defstruct accessor etc. (fn FUNCTION DOCSTRING) (defalias 'websocket-document-function '(macro . #[514 "\300\301D\302F\207" [put quote 'function-documentation] 6 (#$ . 19615)])) (byte-code "\300\301\302\303#\300\301\304\305#\306\307\310\311#\210\306\312\310\313#\210\306\314\310\315#\210\306\316\310\317#\207" [function-put websocket-document-function lisp-indent-function defun doc-string-elt 2 put websocket-on-open function-documentation "Accessor for websocket on-open callback.\nSee `websocket-open' for details.\n\n(fn WEBSOCKET)" websocket-on-message "Accessor for websocket on-message callback.\nSee `websocket-open' for details.\n\n(fn WEBSOCKET)" websocket-on-close "Accessor for websocket on-close callback.\nSee `websocket-open' for details.\n\n(fn WEBSOCKET)" websocket-on-error "Accessor for websocket on-error callback.\nSee `websocket-open' for details.\n\n(fn WEBSOCKET)"] 6) #@44 Generate NBYTES random bytes. (fn NBYTES) (defalias 'websocket-genbytes #[257 "\300\301\"\302\211W\203\211\303\304!I\266\211T\262\202\266\207" [make-string 32 0 random 256] 9 (#$ . 20565)]) #@211 Invoke function WEBSOCKET-CALLBACK with WEBSOCKET and REST args. If an error happens, it is handled according to `websocket-callback-debug-on-error'. (fn WEBSOCKET-CALLBACK CALLBACK-TYPE WEBSOCKET &rest REST) (defalias 'websocket-try-callback #[899 "\211B\262\2037\3031\304!\"0\202_\305!\n>\204*\306\307\310D\"\210\311H#\262\202_\3121E\304!\"0\202_\305!\n>\204U\306\307\310D\"\210\311H#\262)\207" [websocket-callback-debug-on-error debug-on-error cl-struct-websocket-tags (debug error) apply type-of signal wrong-type-argument websocket 6 (error)] 10 (#$ . 20775)]) #@54 Generate a key suitable for the websocket handshake. (defalias 'websocket-genkey #[0 "\300\301\302!!\207" [base64-encode-string websocket-genbytes 16] 3 (#$ . 21387)]) #@120 Calculate the expect value of the accept header. This is based on the KEY from the Sec-WebSocket-Key header. (fn KEY) (defalias 'websocket-calculate-accept #[257 "\301\302P\303\211\304$!\207" [websocket-guid base64-encode-string sha1 nil t] 7 (#$ . 21562)]) #@228 From string S, retrieve the value of N bytes. Return the value as an unsigned integer. The value N must be a power of 2, up to 8. We support getting frames up to 536870911 bytes (2^29 - 1), approximately 537M long. (fn S N) (defalias 'websocket-get-bytes #[514 "\211\300U\2032\301\302\303\"\304\"\305\306\307H\310\"\311H\"\307H\307U\203,\306\311H\312\"\307U\203,\207\313\314\315C\"\207\301\3161c\302\304\311U\203C\317\202[\320U\203M\321\202[\322U\203W\323\202[\324\325\"DC\"0\202n\313\314\326\327\"C\"\262\304\"\207" [8 bindat-get-field bindat-unpack ((:val vec 2 u32)) :val logior lsh 0 32 1 -29 signal websocket-unparseable-frame "Frame value found too large to parse!" (args-out-of-range) u8 2 u16 4 u32 error "websocket-get-bytes: Unknown N: %S" format "Frame unexpectedly short: %s"] 9 (#$ . 21830)]) #@188 Encode the integer VAL in NBYTES of data. NBYTES much be a power of 2, up to 8. This supports encoding values up to 536870911 bytes (2^29 - 1), approximately 537M long. (fn VAL NBYTES) (defalias 'websocket-to-bytes #[514 "\211\300W\203\301\302\300_\"V\203\303\304#\210\211\300U\203G\305\306\"\305\307\"Z\310V\2046\305\311\"\310V\203<\312\313C\"\210\314\315\316\317\"BC\"\207\314\316\320U\203S\321\202k\302U\203]\322\202k\323U\203g\324\202k\303\325\"DC\316BC\"\207" [8 expt 2 error "websocket-to-bytes: Value %d could not be expressed in %d bytes" lsh -32 32 0 -29 signal websocket-frame-too-large bindat-pack ((:val vec 2 u32)) :val vector 1 u8 u16 4 u32 "websocket-to-bytes: Unknown NBYTES: %S"] 10 (#$ . 22670)]) #@58 Retrieve the opcode from first byte of string S. (fn S) (defalias 'websocket-get-opcode #[257 "\300\301\"\210\302\303\304H\"\211\304U\203\305\207\211\301U\203\306\207\211\307U\203#\310\207\211\311U\203+\312\207\211\313U\2033\314\207\211\315U\205:\316\207" [websocket-ensure-length 1 logand 15 0 continuation text 2 binary 8 close 9 ping 10 pong] 5 (#$ . 23423)]) #@171 Parse out the payload length from the string S. We start at position 0, and return a cons of the payload length and how many bytes were consumed from the string. (fn S) (defalias 'websocket-get-payload-len #[257 "\300\301\"\210\302\303\304H\"\211\303U\203 \300\305\"\210\306\301\307O\310\"\305B\207\211\311U\2035\300\312\"\210\306\301\307O\313\"\312B\207\211\301B\207" [websocket-ensure-length 1 logand 127 0 9 websocket-get-bytes nil 8 126 3 2] 6 (#$ . 23804)]) #@74 compiler-macro for inlining `websocket-frame-p'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-frame-p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-frame-p (and (memq (type-of cl-x) cl-struct-websocket-frame-tags) t)) nil] 9 (#$ . 24282)]) (put 'websocket-frame-p 'compiler-macro 'websocket-frame-p--cmacro) #@13 (fn CL-X) (defalias 'websocket-frame-p #[257 "\301!>\205 \302\207" [cl-struct-websocket-frame-tags type-of t] 3 (#$ . 24647)]) (byte-code "\300\301\302\303#\304\305\306\301#\207" [function-put websocket-frame-p side-effect-free error-free put websocket-frame cl-deftype-satisfies] 5) #@79 compiler-macro for inlining `websocket-frame-opcode'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-frame-opcode--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-frame-opcode (progn (or (websocket-frame-p cl-x) (signal 'wrong-type-argument (list 'websocket-frame cl-x))) (aref cl-x 1))) nil] 9 (#$ . 24942)]) (put 'websocket-frame-opcode 'compiler-macro 'websocket-frame-opcode--cmacro) #@67 Access slot "opcode" of `websocket-frame' struct CL-X. (fn CL-X) (defalias 'websocket-frame-opcode #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 1] 5 (#$ . 25382)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-frame-opcode side-effect-free t] 4) #@80 compiler-macro for inlining `websocket-frame-payload'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-frame-payload--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-frame-payload (progn (or (websocket-frame-p cl-x) (signal 'wrong-type-argument (list 'websocket-frame cl-x))) (aref cl-x 2))) nil] 9 (#$ . 25746)]) (put 'websocket-frame-payload 'compiler-macro 'websocket-frame-payload--cmacro) #@68 Access slot "payload" of `websocket-frame' struct CL-X. (fn CL-X) (defalias 'websocket-frame-payload #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 2] 5 (#$ . 26191)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-frame-payload side-effect-free t] 4) #@79 compiler-macro for inlining `websocket-frame-length'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-frame-length--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-frame-length (progn (or (websocket-frame-p cl-x) (signal 'wrong-type-argument (list 'websocket-frame cl-x))) (aref cl-x 3))) nil] 9 (#$ . 26558)]) (put 'websocket-frame-length 'compiler-macro 'websocket-frame-length--cmacro) #@67 Access slot "length" of `websocket-frame' struct CL-X. (fn CL-X) (defalias 'websocket-frame-length #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 3] 5 (#$ . 26998)]) (byte-code "\300\301\302\303#\300\207" [function-put websocket-frame-length side-effect-free t] 4) #@82 compiler-macro for inlining `websocket-frame-completep'. (fn CL-WHOLE-ARG CL-X) (defalias 'websocket-frame-completep--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block websocket-frame-completep (progn (or (websocket-frame-p cl-x) (signal 'wrong-type-argument (list 'websocket-frame cl-x))) (aref cl-x 4))) nil] 9 (#$ . 27362)]) (put 'websocket-frame-completep 'compiler-macro 'websocket-frame-completep--cmacro) #@70 Access slot "completep" of `websocket-frame' struct CL-X. (fn CL-X) (defalias 'websocket-frame-completep #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 4] 5 (#$ . 27817)]) (byte-code "\300\301\302\303#\304\305\306\"\207" [function-put websocket-frame-completep side-effect-free t defalias copy-websocket-frame copy-sequence] 4) #@115 compiler-macro for inlining `make-websocket-frame'. (fn CL-WHOLE &cl-quote &key OPCODE PAYLOAD LENGTH COMPLETEP) (defalias 'make-websocket-frame--cmacro #[385 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\211\203D\211@\305>\203,\211AA\262\202\306>A@\203;\307\262\202\310\311@\"\210\202\210\312\313\314\307 \307    & \207" [plist-member :opcode :payload :length :completep (:opcode :payload :length :completep :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:opcode :payload :length :completep)" cl--defsubst-expand (opcode payload length completep) (cl-block make-websocket-frame (record 'websocket-frame opcode payload length completep))] 16 (#$ . 28245)]) (put 'make-websocket-frame 'compiler-macro 'make-websocket-frame--cmacro) #@95 Constructor for objects of type `websocket-frame'. (fn &key OPCODE PAYLOAD LENGTH COMPLETEP) (defalias 'make-websocket-frame #[128 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\211\203D\211@\305>\203,\211AA\262\202\306>A@\203;\307\262\202\310\311@\"\210\202\210\312\313%\207" [plist-member :opcode :payload :length :completep (:opcode :payload :length :completep :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:opcode :payload :length :completep)" record websocket-frame] 11 (#$ . 29044)]) (byte-code "\300\301\302\303#\304\305\306\307\310\306\311\312\305\303& \207" [function-put make-websocket-frame side-effect-free t cl-struct-define websocket-frame nil cl-structure-object record ((cl-tag-slot) (opcode) (payload) (length) (completep)) cl-struct-websocket-frame-tags] 11) #@72 Given FRAME, return the payload as a utf-8 encoded string. (fn FRAME) (defalias 'websocket-frame-text #[257 "\301\302!>\204\303\304\305D\"\210\306H\307\"\207" [cl-struct-websocket-frame-tags decode-coding-string type-of signal wrong-type-argument websocket-frame 2 utf-8] 6 (#$ . 29888)]) #@116 Using string KEY, mask string DATA according to the RFC. This is used to both mask and unmask data. (fn KEY DATA) (defalias 'websocket-mask #[514 "\300G\301\"\302GW\203-\303\304\305\306\"H\307 \"\"#\266T\262\202\207" [make-string 120 0 \(setf\ seq-elt\) logxor mod 4 seq-elt] 13 (#$ . 30191)]) #@111 Ensure the string S has at most N bytes. Otherwise we throw the error `websocket-incomplete-frame'. (fn S N) (defalias 'websocket-ensure-length #[514 "GW\205 \300\301\302\"\207" [throw websocket-incomplete-frame nil] 5 (#$ . 30515)]) #@131 Encode the FRAME struct to the binary representation. We mask the frame or not, depending on SHOULD-MASK. (fn FRAME SHOULD-MASK) (defalias 'websocket-encode-frame #[514 "\301!>\204\302\303\304D\"\210\305H\301!>\204!\302\303\304D\"\210\306H\301!>\2044\302\303\304D\"\210\307H\205>\310>\205E\311\307!\312\313\314\315\316\267\202h\317\202i\305\202i\306\202i\320\202i\321\202i\322\202i\323\203r\324\202s\317\"C\205\241\315\n\203\203\324\202\204\317 G\325W\203\222 G\202\237 G\326W\203\236\325\202\237\327\"C\205\317G\325Y\205\317\314\330\nG G\325W\203\277\305\202\314 G\326W\203\313\306\202\314\320\"\323\"\205\336 \205\336\314\323\"\205\366\314 \203\362\331  \"\202\364 \323\"%\211G\305U\203\314\332\"\202\211\262\"\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 1 2 4 (continuation ping pong text binary) websocket-genbytes apply unibyte-string append logior #s(hash-table size 6 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (continuation 80 text 84 binary 88 close 92 ping 96 pong 100)) 0 8 9 10 nil 128 126 65536 127 websocket-to-bytes websocket-mask (0)] 18 (#$ . 30760)]) #@205 Read from string S a `websocket-frame' struct with the contents. This only gets complete frames. Partial frames need to wait until the frame finishes. If the frame is not completed, return NIL. (fn S) (defalias 'websocket-read-frame #[257 "\3002\212\301\302\"\210\303!\304\305\306H\"\307>\211\205\310\302\311O!\205,\304\305\302H\"\305U\205<\211\2038\312\2029\302A\\\205D\211@\\\205S\301\"\210O\313\314 \315\203s\f AT\312 A\\O\316\"\262\202t\317 \203\202\200\302\320\306V&\266\2100\207" [websocket-incomplete-frame websocket-ensure-length 1 websocket-get-opcode logand 128 0 (continuation text binary ping pong) websocket-get-payload-len nil 5 make-websocket-frame :opcode :payload websocket-mask :length :completep] 19 (#$ . 31984)]) #@113 Format an error message like command level does. ERR should be a cons of error symbol and error data. (fn ERR) (defalias 'websocket-format-error #[257 "\211@\300N\206\f\301\302@\"A\205\301\303\304\305A\306#\"P\207" [error-message format "peculiar error (%s)" ": %s" mapconcat prin1-to-string ", "] 8 (#$ . 32779)]) #@88 The default error handler used to handle errors in callbacks. (fn WEBSOCKET TYPE ERR) (defalias 'websocket-default-error-handler #[771 "\300\301\302\303\304!#\305#\207" [display-warning websocket format "in callback `%S': %s" websocket-format-error :error] 10 (#$ . 33107)]) (byte-code "\300\301\302\303#\210\300\301\304\305#\210\300\306\302\307#\210\300\306\304\310#\210\300\311\302\312#\210\300\311\304\313#\210\300\314\302\315#\210\300\314\304\316#\210\300\317\302\320#\210\300\317\304\321#\210\300\322\302\323#\210\300\322\304\324#\210\300\325\302\326#\210\300\325\304\327#\210\300\330\302\331#\210\300\330\304\332#\207" [put websocket-unsupported-protocol error-conditions (error websocket-error websocket-unsupported-protocol) error-message "Unsupported websocket protocol" websocket-wss-needs-emacs-24 (error websocket-error websocket-unsupported-protocol websocket-wss-needs-emacs-24) "wss protocol is not supported for Emacs before version 24." websocket-received-error-http-response (error websocket-error websocket-received-error-http-response) "Error response received from websocket server" websocket-invalid-header (error websocket-error websocket-invalid-header) "Invalid HTTP header sent" websocket-illegal-frame (error websocket-error websocket-illegal-frame) "Cannot send illegal frame to websocket" websocket-closed (error websocket-error websocket-closed) "Cannot send message to a closed websocket" websocket-unparseable-frame (error websocket-error websocket-unparseable-frame) "Received an unparseable frame" websocket-frame-too-large (error websocket-error websocket-frame-too-large) "The frame being sent is too large for this emacs to handle"] 4) #@88 Simple list intersection, should function like Common Lisp's `intersection'. (fn A B) (defalias 'websocket-intersect #[514 "\300\211\203\211@\211\235\203\211B\262A\266\202\202\237\207" [nil] 7 (#$ . 34790)]) #@70 Get or create the buffer corresponding to WEBSOCKET. (fn WEBSOCKET) (defalias 'websocket-get-debug-buffer-create #[257 "\301\302\303\304!>\204\305\306\307D\"\210\310H\"!\311!\312U\203$\313!\210\207" [cl-struct-websocket-tags get-buffer-create format "*websocket %s debug*" type-of signal wrong-type-argument websocket 10 buffer-size 0 buffer-disable-undo] 8 (#$ . 35017)]) #@93 In the WEBSOCKET's debug buffer, send MSG, with format ARGS. (fn WEBSOCKET MSG &rest ARGS) (defalias 'websocket-debug #[642 "\205!\301!\212r\211q\210db\210\302c\210\303\304\305C\"\"c\210\306c*\262\207" [websocket-debug websocket-get-debug-buffer-create "[WS] " apply format append "\n"] 9 (#$ . 35407)]) #@196 Verify that OUTPUT contains a valid HTTP response code. The only acceptable one to websocket is responce code 101. A t value will be returned on success, and an error thrown if not. (fn OUTPUT) (defalias 'websocket-verify-response-code #[257 "\300\301\"\204 \302\303\304C\"\210\305\306\"\307\232\204!\302\310\311\305\306\"!C\"\210\312\207" [string-match "^HTTP/1.1 \\([[:digit:]]+\\)" signal websocket-invalid-header "Invalid HTTP status line" match-string 1 "101" websocket-received-error-http-response string-to-number t] 7 (#$ . 35725)]) #@102 From header-containing OUTPUT, parse out the list from a possibly repeated field. (fn OUTPUT FIELD) (defalias 'websocket-parse-repeated-field #[514 "\300\301\203)\302\303\304\"#\203)\305\225\211\262\203\306\307\310\305\"\311\"\"\262\202\207" [0 nil string-match format " \n%s: \\(.*\\) \n" 1 append split-string match-string ", ?"] 10 (#$ . 36279)]) #@390 Using the WEBSOCKET's filter and connection, process the FRAME. This returns a lambda that should be executed when all frames have been processed. If the frame has a payload, the lambda has the frame passed to the filter slot of WEBSOCKET. If the frame is a ping, the lambda has a reply with a pong. If the frame is a close, the lambda has connection termination. (fn WEBSOCKET FRAME) (defalias 'websocket-process-frame #[514 "\301!>\204\302\303\304D\"\210\211\305H\211\306\267\202)\307\310#\207\307\311#\207\307\312\"\207\313\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 1 #s(hash-table size 5 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (continuation 24 text 24 binary 24 ping 30 close 36)) make-closure #[0 "\302\303\304\300\301$\207" [V0 V1 websocket-try-callback websocket-on-message on-message] 5] #[0 "\303\300\304\305\306\307\301!\n>\204\310\311\305\301D\"\210\301\312H\313\314%\"\207" [V0 V1 cl-struct-websocket-frame-tags websocket-send record websocket-frame pong type-of signal wrong-type-argument 2 nil t] 9] #[0 "\302\303\300! >\204\304\305\306\300D\"\210\300\307H!\207" [V0 cl-struct-websocket-tags delete-process type-of signal wrong-type-argument websocket 13] 5] #[0 "\300\207" [nil] 1]] 7 (#$ . 36652)]) #@92 This handles input processing for both the client and server filters. (fn WEBSOCKET TEXT) (defalias 'websocket-process-input-on-open-ws #[514 "\302\211\303\304\302O!\211\262\2031\305\"B\262\211\306!>\204(\307\310\311D\"\210\312H\\\262\202GV\203S\306! >\204H\307\310\313D\"\210\211\314\302OI\266\237\211\205e\211@\211 \210A\266\202\202U\207" [cl-struct-websocket-frame-tags cl-struct-websocket-tags nil 0 websocket-read-frame websocket-process-frame type-of signal wrong-type-argument websocket-frame 3 websocket 16] 11 (#$ . 37963)]) #@71 To the WEBSOCKET, send TEXT as a complete frame. (fn WEBSOCKET TEXT) (defalias 'websocket-send-text #[514 "\300\301\302\303\304\305\306\"\307\310&\"\207" [websocket-send make-websocket-frame :opcode text :payload encode-coding-string raw-text :completep t] 11 (#$ . 38537)]) #@69 Check FRAME for correctness, returning true if correct. (fn FRAME) (defalias 'websocket-check #[257 "\301!>\204\302\303\304D\"\210\211\305H\306>\203,\301!>\204&\302\303\304D\"\210\211\307H\206\202\301!>\204;\302\303\304D\"\210\211\305H\310>\206\202\301!>\204R\302\303\304D\"\210\211\305H\311=\205\202\301!>\204i\302\303\304D\"\210\211\307H?\205\202\301!>\204\302\303\304D\"\210\211\312H\207" [cl-struct-websocket-frame-tags type-of signal wrong-type-argument websocket-frame 1 (text binary continuation) 2 (ping pong) close 4] 5 (#$ . 38823)]) #@702 To the WEBSOCKET server, send the FRAME. This will raise an error if the frame is illegal. The error signaled may be of type `websocket-illegal-frame' if the frame is malformed in some way, also having the condition type of `websocket-error'. The data associated with the signal is the frame being sent. If the websocket is closed a signal `websocket-closed' is sent, also with `websocket-error' condition. The data in the signal is also the frame. The frame may be too large for this buid of Emacs, in which case `websocket-frame-too-large' is returned, with the data of the size of the frame which was too large to process. This also has the `websocket-error' condition. (fn WEBSOCKET FRAME) (defalias 'websocket-send #[514 "\302!\204\f\303\304C\"\210\305\306\307!>\204\303\310\311D\"\210\312H\307!>\2042\303\310\311D\"\210\313H$\210\314!\204C\303\315C\"\210\316\307! >\204S\303\310\317D\"\210\320H\321\307! >\204i\303\310\317D\"\210\322H?\"\"\207" [cl-struct-websocket-frame-tags cl-struct-websocket-tags websocket-check signal websocket-illegal-frame websocket-debug "Sending frame, opcode: %s payload: %s" type-of wrong-type-argument websocket-frame 1 2 websocket-openp websocket-closed process-send-string websocket 13 websocket-encode-frame 9] 10 (#$ . 39406)]) #@79 Check WEBSOCKET and return non-nil if the connection is open. (fn WEBSOCKET) (defalias 'websocket-openp #[257 "\211\2052\301!>\204\302\303\304D\"\210\211\305H\306=?\2052\307\301!>\204,\302\303\304D\"\210\310H!\311>\207" [cl-struct-websocket-tags type-of signal wrong-type-argument websocket 1 close process-status 13 (open run)] 6 (#$ . 40719)]) #@71 Close WEBSOCKET and erase all the old websocket data. (fn WEBSOCKET) (defalias 'websocket-close #[257 "\301\302\"\210\303\304\305#\210\306!\2032\307\310\311\312\313\211\314%\"\210\315!>\204+\316\317\320D\"\210\211\211\321\322I\266\323\315!>\204B\316\317\320D\"\210\324H!\207" [cl-struct-websocket-tags websocket-debug "Closing websocket" websocket-try-callback websocket-on-close on-close websocket-openp websocket-send record websocket-frame close nil t type-of signal wrong-type-argument websocket 1 closed delete-process 13] 9 (#$ . 41084)]) #@3483 Open a websocket connection to URL, returning the `websocket' struct. The PROTOCOL argument is optional, and setting it will declare to the server that this client supports the protocols in the list given. We will require that the server also has to support that protocols. Similar logic applies to EXTENSIONS, which is a list of conses, the car of which is a string naming the extension, and the cdr of which is the list of parameter strings to use for that extension. The parameter strings are of the form "key=value" or "value". EXTENSIONS can be NIL if none are in use. An example value would be ("deflate-stream" . ("mux" "max-channels=4")). Cookies that are set via `url-cookie-store' will be used during communication with the server, and cookies received from the server will be stored in the same cookie storage that the `url-cookie' package uses. Optionally you can specify ON-OPEN, ON-MESSAGE and ON-CLOSE callbacks as well. The ON-OPEN callback is called after the connection is established with the websocket as the only argument. The return value is unused. The ON-MESSAGE callback is called after receiving a frame, and is called with the websocket as the first argument and `websocket-frame' struct as the second. The return value is unused. The ON-CLOSE callback is called after the connection is closed, or failed to open. It is called with the websocket as the only argument, and the return value is unused. The ON-ERROR callback is called when any of the other callbacks have an error. It takes the websocket as the first argument, and a symbol as the second argument either `on-open', `on-message', or `on-close', and the error as the third argument. Do NOT rethrow the error, or else you may miss some websocket messages. You similarly must not generate any other errors in this method. If you want to debug errors, set `websocket-callback-debug-on-error' to t, but this also can be dangerous is the debugger is quit out of. If not specified, `websocket-default-error-handler' is used. For each of these event handlers, the client code can store arbitrary data in the `client-data' slot in the returned websocket. The following errors might be thrown in this method or in websocket processing, all of them having the error-condition `websocket-error' in addition to their own symbol: `websocket-unsupported-protocol': Data in the error signal is the protocol that is unsupported. For example, giving a URL starting with http by mistake raises this error. `websocket-wss-needs-emacs-24': Trying to connect wss protocol using Emacs < 24 raises this error. You can catch this error also by `websocket-unsupported-protocol'. `websocket-received-error-http-response': Data in the error signal is the integer error number. `websocket-invalid-header': Data in the error is a string describing the invalid header received from the server. `websocket-unparseable-frame': Data in the error is a string describing the problem with the frame. `nowait': If NOWAIT is true, return without waiting for the connection to complete. `custom-headers-alist': An alist of custom headers to pass to the server. The car is the header name, the cdr is the header value. These are different from the extensions because it is not related to the websocket protocol. (fn URL &key PROTOCOLS EXTENSIONS (ON-OPEN \='identity) (ON-MESSAGE (lambda (_w _f))) (ON-CLOSE \='identity) (ON-ERROR \='websocket-default-error-handler) (NOWAIT nil) (CUSTOM-HEADER-ALIST nil)) (defalias 'websocket-open #[385 "\303\304\"A@\303\305\"A@\303\306\"\206\307A@\303\310\"\206 \311\312DA@\303\313\"\206*\314A@\303\315\"\2065\316A@\303\317\"A@\303\320\"A@\211\203r\211@\321>\203Z\211AA\262\202G\322\n>A@\203i\311\262\202G\323\324@\"\210\202G\210\325\326 \"\327 !\330 \331\211\332!\n>\204\221\333\334\335D\"\210\336H\337\235\203\236\332!\n>\204\250\333\334\335D\"\210\336H\340\232\203\264\341\202\265\342\332!\n>\204\305\333\334\335D\"\210\211\343H\206\365\332!\n>\204\332\333\334\335D\"\210\211\336H\205\365\344\332!\n>\204\360\333\334\335D\"\210\336H\345\"\262\346U\203\n\211\342=\203\347\202L\350\202L\332!\n>\204\333\334\335D\"\210\211\343H\206J\332!\n>\204/\333\334\335D\"\210\211\336H\205J\344\332!\n>\204E\333\334\335D\"\210\336H\345\"\262\332!\n>\204\\\333\334\335D\"\210\351H\341=\203{\352\353\354\311\355\356 \317&\n\266\203\202\265\3571\223\360\311\361\317&0\266\203\202\265\210\333\362\363C\"\266\203\202\265\333\364\332!\n>\204\260\333\334\335D\"\210\336HC\"\365\366\367\306\310\313\315\304\305\370\371\"\372\373!&\204\341\323\374\"\210\375\376#\210\377\201@\"\210\201A\201B &\"\210\201C\311\"\210\201D  &\210*\207" [coding-system-for-read coding-system-for-write cl-struct-url-tags plist-member :protocols :extensions :on-open (nil identity) :on-message nil #[514 "\300\207" [nil] 3 "\n\n(fn W F)"] :on-close (nil identity) :on-error (nil websocket-default-error-handler) :nowait :custom-header-alist (:protocols :extensions :on-open :on-message :on-close :on-error :nowait :custom-header-alist :allow-other-keys) :allow-other-keys error "Keyword argument %s not one of (:protocols :extensions :on-open :on-message :on-close :on-error :nowait :custom-header-alist)" format "websocket to %s" url-generic-parse-url websocket-genkey binary type-of signal wrong-type-argument url 1 ("ws" "wss") "ws" plain tls 5 url-scheme-get-property default-port 0 443 80 4 make-network-process :name :buffer :host :service (debug wrong-number-of-arguments) open-network-stream :type websocket-wss-needs-emacs-24 "wss" websocket-unsupported-protocol websocket-inner-create :conn :url mapcar car :accept-string websocket-calculate-accept "Could not establish the websocket connection to %s" process-put :websocket set-process-filter #[514 "\300\301\"\302\"\207" [process-get :websocket websocket-outer-filter] 6 "\n\n(fn PROCESS OUTPUT)"] set-process-sentinel websocket-sentinel set-process-query-on-exit-flag websocket-ensure-handshake] 35 (#$ . 41653)]) #@69 (fn URL CONN KEY PROTOCOLS EXTENSIONS CUSTOM-HEADER-ALIST NOWAIT) (defalias 'websocket-sentinel #[1799 "\300\301&\207" [make-closure #[514 "\307\310\"\311\312#\210\313!\306\203\"\211\314=\203\"\315\300\301\302\303\304\305\306&\210\211\316>\205F\317!>\2048\320\321\322D\"\210\323H\324=?\205F\325\326\327#\207" [V0 V1 V2 V3 V4 V5 V6 process-get :websocket websocket-debug "State change to %s" process-status open websocket-ensure-handshake (closed failed exit signal) type-of signal wrong-type-argument websocket 1 closed websocket-try-callback websocket-on-close on-close cl-struct-websocket-tags] 12 "\n\n(fn PROCESS CHANGE)"]] 16 (#$ . 47773)]) #@69 (fn URL CONN KEY PROTOCOLS EXTENSIONS CUSTOM-HEADER-ALIST NOWAIT) (defalias 'websocket-ensure-handshake #[1799 "\302!\303\304\"\305!>\204\306\307\310D\"\210\211\311H\312=\205\202\313!\314\203-\315\202.\316D>\205\202\317\320 \305!>\204H\306\307\310D\"\210\321H$\210\322\323\324\305! >\204c\306\307\325D\"\210\326H\211G\327V\203q\211\202r\330\262\331    %#\"\207" [cl-struct-websocket-tags cl-struct-url-tags url-generic-parse-url process-get :websocket type-of signal wrong-type-argument websocket 1 connecting process-status run connect open websocket-debug "Sending handshake, key: %s, acceptance: %s" 15 process-send-string format "GET %s HTTP/1.1 \n%s" url 6 0 "/" websocket-create-headers] 20 (#$ . 48458)]) #@77 On opening URL, process the HEADERS sent from the server. (fn URL HEADERS) (defalias 'websocket-process-headers #[514 "\301\302\"\205\303!\304\305\306\"!)\207" [url-current-object string-match "Set-Cookie: (.*) \n" url-generic-parse-url url-cookie-handle-set-cookie match-string 1] 6 (#$ . 49219)]) #@244 Filter the WEBSOCKET server's OUTPUT. This will parse headers and process frames repeatedly until there is no more output or the connection closes. If the websocket connection is invalid, the connection will be closed. (fn WEBSOCKET OUTPUT) (defalias 'websocket-outer-filter #[514 "\301\302#\210\303\304!>\204\305\306\307D\"\210\310HP\303\304!>\204,\305\306\307D\"\210\211\310\303I\266\304!>\204C\305\306\307D\"\210\311H\312=\203\337\313\314\"\211\262\203\310\315\\\211\262\203\310\3161\207\317!\210\320\"\210\321\304!>\204}\305\306\307D\"\210\322H\"0\210\202\247\323!\210\304!>\204\235\305\306\307D\"\210\324H\325#\266\304!>\204\267\305\306\307D\"\210\211\311\326I\266\327\330\325#\210\202\337\304!>\204\330\305\306\307D\"\210\211\310I\266\304!>\204\357\305\306\307D\"\210\311H\326=\205\331\206\377\332\303O\"\207" [cl-struct-websocket-tags websocket-debug "Received: %s" nil type-of signal wrong-type-argument websocket 16 1 connecting string-match " \n \n" 4 (error) websocket-verify-response-code websocket-verify-headers websocket-process-headers 10 websocket-close 6 on-open open websocket-try-callback websocket-on-open websocket-process-input-on-open-ws 0] 10 (#$ . 49532)]) #@276 Based on WEBSOCKET's data, ensure the headers in OUTPUT are valid. The output is assumed to have complete headers. This function will either return t or call `error'. This has the side-effect of populating the list of server extensions to WEBSOCKET. (fn WEBSOCKET OUTPUT) (defalias 'websocket-verify-headers #[514 "\302\303\304!>\204\305\306\307D\"\210\310H!P\311\312#\210\313\"\204*\305\314\315C\"\210\210\316\311\317\"\210\313\320\"\204?\305\314\321C\"\210\311\322\"\210\313\323\"\204Q\305\314\324C\"\210\304!>\204`\305\306\307D\"\210\325H\203\267\304!>\204u\305\306\307D\"\210\325H\211\203\266\211@\311\326#\210\313\327\330\"\"\203\223\211C\202\230\305\314\331C\"\304!>\204\250\305\306\307D\"\210\211\332I\266A\266\202\202x\210\333\334\"\335\211\203\365\211@\336\337\"@\211\304!>\204\332\305\306\307\nD\"\210\340H\235\204\355\211\235\204\355\211B\262\210A\266\202\202\275\210\211\203\305\314\327\341\"C\"\210\304!>\204\305\306\307D\"\210\211\342I\266)\316\207" [cl-struct-websocket-tags case-fold-search "Sec-Web[Ss]ocket-Accept: " regexp-quote type-of signal wrong-type-argument websocket 15 websocket-debug "Checking for accept header regexp: %s" string-match websocket-invalid-header "Incorrect handshake from websocket: is this really a websocket connection?" t "Checking for upgrade header" " \nUpgrade: websocket \n" "No 'Upgrade: websocket' header found" "Checking for connection header" " \nConnection: upgrade \n" "No 'Connection: upgrade' header found" 11 "Checking for protocol match: %s" format " \nSec-Websocket-Protocol: %s \n" "Incorrect or missing protocol returned by the server." 7 websocket-parse-repeated-field "Sec-WebSocket-Extensions" nil split-string "; ?" 12 "Non-requested extensions returned by server: %S" 8] 12 (#$ . 50809)]) #@50 A list of current websockets live on any server. (defvar websocket-server-websockets nil (#$ . 52653)) #@557 Open a websocket server on PORT. If the plist contains a `:host' HOST pair, this value will be used to configure the addresses the socket listens on. The symbol `local' specifies the local host. If unspecified or nil, the socket will listen on all addresses. This also takes a plist of callbacks: `:on-open', `:on-message', `:on-close' and `:on-error', which operate exactly as documented in the websocket client function `websocket-open'. Returns the connection, which should be kept in order to pass to `websocket-server-close'. (fn PORT &rest PLIST) (defalias 'websocket-server #[385 "\300\301\302\303\"\304\305\306\307\310\305\311\312\313\314\315\316\317\320\321\320\"\322&\207" [make-network-process :name format "websocket server on port %s" :server t :family ipv4 :noquery :filter websocket-server-filter :log websocket-server-accept :filter-multibyte nil :plist :host plist-get :service] 23 (#$ . 52763)]) #@82 Closes the websocket, as well as all open websockets for this server. (fn CONN) (defalias 'websocket-server-close #[257 "\302\211\203O\211@\303! >\204\304\305\306D\"\210\211\307H=\203H\303! >\204.\304\305\306D\"\210\211\310H\311=\203D\211\235\204H\211B\262\202H\312!\210A\266\202\202\210\211\211\203c\211@\313\"A\266\202\202Q\266\314!\207" [websocket-server-websockets cl-struct-websocket-tags nil type-of signal wrong-type-argument websocket 14 1 closed websocket-close remove delete-process] 8 (#$ . 53694)]) #@78 Accept a new websocket connection from a client. (fn SERVER CLIENT MESSAGE) (defalias 'websocket-server-accept #[771 "\301\302\303\304\305\306\307\310 \307\"\206\311\312\310\312\"\206\313\314\310\314\"\206(\311\315\316\"\262\317\310\317\"\2068\320\321\310\322\"\323\324\325\310\323\"\"&\211\235\204S\211B\326\327#\210\330\331\211#\210\332\333\"\207" [websocket-server-websockets websocket-inner-create :server-conn :conn :url :server-p t :on-open process-get identity :on-message #[514 "\300\207" [nil] 3 "\n\n(fn WS FRAME)"] :on-close make-closure #[257 "\302 \"\300!\207" [V0 websocket-server-websockets remove] 4 "\n\n(fn WS)"] :on-error websocket-default-error-handler :protocols :protocol :extensions mapcar car process-put :websocket set-process-coding-system binary set-process-sentinel #[514 "\301\302\"\303\304#\210\305!\306>\205/\307!>\204!\310\311\312D\"\210\211\313H\314=?\205/\315\316\317#\207" [cl-struct-websocket-tags process-get :websocket websocket-debug "State change to %s" process-status (closed failed exit signal) type-of signal wrong-type-argument websocket 1 closed websocket-try-callback websocket-on-close on-close] 7 "\n\n(fn PROCESS CHANGE)"]] 28 (#$ . 54241)]) #@256 Create connections headers for the given URL, KEY, PROTOCOL, and EXTENSIONS. Additionally, the CUSTOM-HEADERS-ALIST is passed from the client. All these parameters are defined as in `websocket-open'. (fn URL KEY PROTOCOL EXTENSIONS CUSTOM-HEADERS-ALIST) (defalias 'websocket-create-headers #[1285 "\301!\302!\203c\303\304\305!>\204\306\307\310D\"\210\311H\305!>\204-\306\307\310D\"\210\211\312H\206]\305!>\204B\306\307\310D\"\210\211\313H\205]\314\305!>\204X\306\307\310D\"\210\313H\315\"\262#\202u\305!>\204r\306\307\310D\"\210\211\311H\316\317!@\305!>\204\213\306\307\310D\"\210\313H\320\232#\303\321\205\240\322\323 \324#\324P\205\256\303\325\322\326 \327#\"\205\263\322\330\n\324# \205\277\324P\324\260  $\207" [cl-struct-url-tags url-generic-parse-url url-port-if-non-default format "%s:%s" type-of signal wrong-type-argument url 4 5 1 url-scheme-get-property default-port url-cookie-generate-header-lines url-path-and-query "wss" "Host: %s \nUpgrade: websocket \nConnection: Upgrade \nSec-WebSocket-Key: %s \nSec-WebSocket-Version: 13 \n" mapconcat #[257 "\300\301\"\207" [format "Sec-WebSocket-Protocol: %s"] 4 "\n\n(fn PROTOCOL)"] " \n" "Sec-WebSocket-Extensions: %s \n" #[257 "\211@A\205\300A\205\301\302A\300#Q\207" ["; " mapconcat identity] 7 "\n\n(fn EXT)"] ", " #[257 "\300\301@A#\207" [format "%s: %s"] 5 "\n\n(fn CONS)"]] 17 (#$ . 55486)]) #@102 Get the websocket response from client WEBSOCKET. (fn WEBSOCKET CLIENT-PROTOCOLS CLIENT-EXTENSIONS) (defalias 'websocket-get-server-response #[771 "\301\302!>\204\303\304\305D\"\210\306H\307\310\302!>\204(\303\304\305\nD\"\210\311H\"\211\2058\312\313\307#\307P\262\310\302 !>\204M\303\304\305 D\"\210\314H\"\211\205]\312\315\307#\307P\262\307\260\207" [cl-struct-websocket-tags "HTTP/1.1 101 Switching Protocols \nUpgrade: websocket \nConnection: Upgrade \nSec-WebSocket-Accept: " type-of signal wrong-type-argument websocket 15 " \n" websocket-intersect 11 mapconcat #[257 "\300\301\"\207" [format "Sec-WebSocket-Protocol: %s"] 4 "\n\n(fn PROTOCOL)"] 12 #[257 "\300\301\"\207" [format "Sec-Websocket-Extensions: %s"] 4 "\n\n(fn EXTENSION)"]] 13 (#$ . 56916)]) #@78 This acts on all OUTPUT from websocket clients PROCESS. (fn PROCESS OUTPUT) (defalias 'websocket-server-filter #[514 "\301\302\"\303!>\204\304\305\306D\"\210\211\307HP\303!>\204'\304\305\306D\"\210\211\307\310I\266\303!>\204=\304\305\306D\"\210\311H\312=\203\345\313\314\"\211\205P\315\\\262\211\203\316\316!\211\203\255\303!>\204m\304\305\306D\"\210\211\317\320\321\322\"!I\266\323\324\321\325\"\321\326\"#\"\210\303!>\204\233\304\305\306D\"\210\211\311\327I\266\330\331\332#\266\202\276\333\334\"\210\323\335\"\210\336!\266GTV\205\344\337\310O\"\207\303!>\204\335\304\305\306D\"\210\211\307I\262\207\303!>\204\364\304\305\306D\"\210\311H\327=\203\340\"\207\303!>\204\304\305\306D\"\210\311H\341=\205\333\342!\207" [cl-struct-websocket-tags process-get :websocket type-of signal wrong-type-argument websocket 16 nil 1 connecting string-match " \n \n" 4 websocket-verify-client-headers 15 websocket-calculate-accept plist-get :key process-send-string websocket-get-server-response :protocols :extensions open websocket-try-callback websocket-on-open on-open message "Invalid client headers found in: %s" "HTTP/1.1 400 Bad Request \n \n" websocket-close websocket-server-filter websocket-process-input-on-open-ws closed "WARNING: Should not have received further input on closed websocket"] 14 (#$ . 57715)]) #@300 Verify the headers from the WEBSOCKET client connection in OUTPUT. Unlike `websocket-verify-headers', this is a quieter routine. We don't want to error due to a bad client, so we just print out messages and a plist containing `:key', the websocket key, `:protocols' and `:extensions'. (fn OUTPUT) (defalias 'websocket-verify-client-headers #[257 "\3012\216\302\303\304\305\"\204\306\307!\210\310\301\303\"\210\304\311\"\204(\306\312!\210\310\301\303\"\210\304\313\"\2048\306\314!\210\310\301\303\"\210\304\315\"\203M\316\303\317\320\321\"#\262\202V\306\322!\210\310\301\303\"\210\304\323\"\204f\306\324!\210\310\301\303\"\210\304\325\"\203x\316\326\327\330\"#\262\304\331\"\203\212\316\332\327\333\"#\262)\2620\207" [case-fold-search --cl-block-nil-- t nil string-match "HTTP/1.1" message "Websocket client connection: HTTP/1.1 not found" throw "^Host: " "Websocket client connection: Host header not found" "^Upgrade: websocket \n" "Websocket client connection: Upgrade: websocket not found" "^Sec-WebSocket-Key: \\([[:graph:]]+\\) \n" plist-put :key match-string 1 "Websocket client connect: No key sent" "^Sec-WebSocket-Version: 13" "Websocket client connect: Websocket version 13 not found" "^Sec-WebSocket-Protocol:" :protocols websocket-parse-repeated-field "Sec-Websocket-Protocol" "^Sec-WebSocket-Extensions:" :extensions "Sec-Websocket-Extensions"] 9 (#$ . 59119)]) (provide 'websocket)