fast-websocket

2015-10-31

fast-websocket

Build Status Coverage Status Quicklisp dist

Optimized low-level WebSocket protocol parser/composer.

Warning

This software is still BETA quality. The APIs will be likely to change.

Usage

(use-package :fast-websocket)

(let* ((ws (make-ws))
       (body (make-string-output-stream))
       (parser (make-parser ws
                            :require-masking t
                            :message-callback
                            (lambda (message)
                              (princ message body))
                            :close-callback
                            (lambda (payload &key code)
                              (format t "Client closed a connection: ~A (Code: ~D)~%" payload code)))))
  (funcall parser (make-array 11 :element-type '(unsigned-byte 8)
                              :initial-contents (list 129 133 225 106 10 29 169 15 102 113 142)))

  (princ (opcode-name (ws-opcode ws)))
  ;-> :TEXT

  (princ (get-output-stream-string body))
  ;-> Hello

  t)

(compose-frame "bye" :type :close :code (error-code :protocol-error))
;=> #(136 5 3 234 98 121 101)

Installation

cd ~/common-lisp
git clone https://github.com/fukamachi/fast-websocket
(ql:quickload :fast-websocket)

See Also

Author

  • Eitaro Fukamachi (e.arrows@gmail.com)

Copyright (c) 2015 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 2-Clause License.

Author
Eitaro Fukamachi
License
BSD 2-Clause