Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the websocket-driver Reference Manual, version 0.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 06:09:12 2022 GMT+0.
Next: Systems, Previous: The websocket-driver Reference Manual, Up: The websocket-driver Reference Manual [Contents][Index]
This library provides WebSocket server & client implementation for Common Lisp.
WebSocket server implementation is designed to work with Clack, which is a abstraction layer for web servers.
(ql:quickload '(:websocket-driver-server :clack))
(use-package :websocket-driver)
(defvar *echo-server*
(lambda (env)
(let ((ws (make-server env)))
(on :message ws
(lambda (message)
(send ws message)))
(lambda (responder)
(declare (ignore responder))
(start-connection ws)))))
;; Start Wookie server
(clack:clackup *echo-server* :server :wookie :port 5000)
The backend server can be changed by replacing :wookie
by other servers.
(ql:quickload :websocket-driver-client)
(defvar *client* (wsd:make-client "ws://localhost:5000/echo"))
(wsd:start-connection *client*)
(wsd:on :message *client*
(lambda (message)
(format t "~&Got: ~A~%" message)))
(wsd:send *client* "Hi")
(wsd:close-connection *client*)
Returns a new SERVER
object. The ENV
is a property list represents server information, which Clack provides.
The max-length
is the maximum message size allowed. The default is #x3ffffff
. If at any time it stays bigger than this, the connection will be closed with code 1009 (too-large).
The accept-protocols
is a list of custom protocol names as strings. This will be used for checking Sec-WebSocket-Protocol
header client sent. The default is an empty list.
The additional-headers
is an association list which represents HTTP headers to use in WebSocket handshake response. The default is an empty list.
Returns a new CLIENT
object. The URL
is a string to connect.
Additional keyword arguments max-length
, accept-protocols
and additional-headers
are shared with make-server
.
The base class for server
and client
.
As this inherits event-emitter
, its object can be attached event listerners by on
.
Called when the socket becomes open.
(on :open ws
(lambda ()
(format t "Connected.~%")))
Called when a message is received. The callback function takes a MESSAGE
as an argument which is either a string in the case of a text message or an (UNSIGNED-BYTE 8)
vector in the case of a binary message.
(on :message ws
(lambda (message)
(format t "Received: ~S~%" message)))
Called when a protocol error occurs due to the other peer sending an invalid byte sequence. The callback function takes a PROTOCOL-ERROR
as an argument.
(on :error ws
(lambda (error)
(format t "Got an error: ~S~%" error)))
Called when the socket becomes closed. The CALLBACK
function takes CODE
and REASON
as arguments.
(on :close ws
(lambda (&key code reason)
(format t "Closed because '~A' (Code=~A)~%" reason code)))
The class for WebSocket (version 13) server implementation.
The class for WebSocket client implementation.
(start-connection ws)
Initiates the protocol by sending the handshake - either the response for a server-side driver or the request for a client-side one. This should be the first method you invoke. Returns T
if a handshake was sent.
(send ws data &key start end type code callback)
Sends DATA
over the socket.
(send-text ws message &key start end callback)
Sends a text message over the socket.
(send-binary ws usb8-vector &key start end callback)
Takes an (UNSIGNED-BYTE 8)
vector and sends them as a binary message.
(send-ping ws &optional message callback)
Sends a ping frame over the socket, queueing it if necessary.
(close-connection ws)
Initiates the closing handshake if the socket is still open.
(version driver)
Returns the WebSocket version in use as a string (ex. "hybi-13").
(protocol driver)
Returns a string containing the selected subprotocol, if any was agreed upon using the Sec-WebSocket-Protocol
mechanism.
(ready-state ws)
Returns the connection state as a keyword, which is one of :connecting
, :open
, :closing
and :closed
.
Copyright (c) 2014 Eitaro Fukamachi (e.arrows@gmail.com)
Licensed under the BSD 2-Clause License.
Next: Modules, Previous: Introduction, Up: The websocket-driver Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
Next: websocket-driver-server, Previous: Systems, Up: Systems [Contents][Index]
WebSocket protocol handler
Eitaro Fukamachi
BSD 2-Clause
0.2.0
Next: websocket-driver-base, Previous: websocket-driver, Up: Systems [Contents][Index]
WebSocket protocol handler
Eitaro Fukamachi
BSD 2-Clause
0.2.0
src (module).
Next: websocket-driver-client, Previous: websocket-driver-server, Up: Systems [Contents][Index]
WebSocket protocol handler
Eitaro Fukamachi
BSD 2-Clause
0.2.0
src (module).
Previous: websocket-driver-base, Up: Systems [Contents][Index]
Eitaro Fukamachi
BSD 2-Clause
0.2.0
src (module).
Next: Files, Previous: Systems, Up: The websocket-driver Reference Manual [Contents][Index]
Modules are listed depth-first from the system components tree.
Next: websocket-driver-base/src, Previous: Modules, Up: Modules [Contents][Index]
websocket-driver-server (system).
Next: websocket-driver-client/src, Previous: websocket-driver-server/src, Up: Modules [Contents][Index]
websocket-driver-base (system).
Previous: websocket-driver-base/src, Up: Modules [Contents][Index]
websocket-driver-client (system).
Next: Packages, Previous: Modules, Up: The websocket-driver Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: websocket-driver-server/websocket-driver-server.asd, Previous: Lisp, Up: Lisp [Contents][Index]
websocket-driver (system).
Next: websocket-driver-base/websocket-driver-base.asd, Previous: websocket-driver/websocket-driver.asd, Up: Lisp [Contents][Index]
websocket-driver-server (system).
Next: websocket-driver-client/websocket-driver-client.asd, Previous: websocket-driver-server/websocket-driver-server.asd, Up: Lisp [Contents][Index]
websocket-driver-base (system).
Next: websocket-driver-server/src/server.lisp, Previous: websocket-driver-base/websocket-driver-base.asd, Up: Lisp [Contents][Index]
websocket-driver-client (system).
Next: websocket-driver-server/src/ws/server.lisp, Previous: websocket-driver-client/websocket-driver-client.asd, Up: Lisp [Contents][Index]
ws/server.lisp (file).
src (module).
make-server (function).
Next: websocket-driver-base/src/driver.lisp, Previous: websocket-driver-server/src/server.lisp, Up: Lisp [Contents][Index]
src (module).
Next: websocket-driver-base/src/ws/base.lisp, Previous: websocket-driver-server/src/ws/server.lisp, Up: Lisp [Contents][Index]
ws/base.lisp (file).
src (module).
websocket-p (function).
Next: websocket-driver-base/src/util.lisp, Previous: websocket-driver-base/src/driver.lisp, Up: Lisp [Contents][Index]
util.lisp (file).
src (module).
Next: websocket-driver-client/src/ws/client.lisp, Previous: websocket-driver-base/src/ws/base.lisp, Up: Lisp [Contents][Index]
src (module).
+guid+ (special variable).
Next: websocket-driver-client/src/client.lisp, Previous: websocket-driver-base/src/util.lisp, Up: Lisp [Contents][Index]
src (module).
Previous: websocket-driver-client/src/ws/client.lisp, Up: Lisp [Contents][Index]
ws/client.lisp (file).
src (module).
make-client (function).
Next: Definitions, Previous: Files, Up: The websocket-driver Reference Manual [Contents][Index]
Packages are listed by definition order.
Next: websocket-driver.ws.base, Previous: Packages, Up: Packages [Contents][Index]
wsd
common-lisp.
websocket-p (function).
Next: websocket-driver-client-asd, Previous: websocket-driver, Up: Packages [Contents][Index]
common-lisp.
Next: websocket-driver-base-asd, Previous: websocket-driver.ws.base, Up: Packages [Contents][Index]
Next: websocket-driver-client, Previous: websocket-driver-client-asd, Up: Packages [Contents][Index]
Next: websocket-driver.util, Previous: websocket-driver-base-asd, Up: Packages [Contents][Index]
common-lisp.
make-client (function).
Next: websocket-driver-asd, Previous: websocket-driver-client, Up: Packages [Contents][Index]
common-lisp.
+guid+ (special variable).
Next: websocket-driver.ws.client, Previous: websocket-driver.util, Up: Packages [Contents][Index]
Next: websocket-driver.server, Previous: websocket-driver-asd, Up: Packages [Contents][Index]
client (class).
Next: websocket-driver-server-asd, Previous: websocket-driver.ws.client, Up: Packages [Contents][Index]
common-lisp.
make-server (function).
Next: websocket-driver.ws.server, Previous: websocket-driver.server, Up: Packages [Contents][Index]
Previous: websocket-driver-server-asd, Up: Packages [Contents][Index]
server (class).
Next: Indexes, Previous: Packages, Up: The websocket-driver Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Next: Internals, Previous: Definitions, Up: Definitions [Contents][Index]
Next: Generic functions, Previous: Public Interface, Up: Public Interface [Contents][Index]
Next: Standalone methods, Previous: Ordinary functions, Up: Public Interface [Contents][Index]
automatically generated reader method
automatically generated reader method
automatically generated writer method
automatically generated writer method
Next: Classes, Previous: Generic functions, Up: Public Interface [Contents][Index]
Previous: Standalone methods, Up: Public Interface [Contents][Index]
ws.
(websocket-driver.ws.client::generate-key)
key.
This slot is read-only.
"hybi-13"
:require-masking
event-emitter.
:socket
(quote nil)
:accept-protocols
(or null string)
67108863
:max-length
fixnum
0
(quote nil)
:additional-headers
(make-array 0 :adjustable t :fill-pointer 0)
:require-masking
(fast-websocket.ws:make-ws)
(make-hash-table :test (quote equalp))
(bordeaux-threads:make-recursive-lock)
This slot is read-only.
Previous: Public Interface, Up: Definitions [Contents][Index]
Next: Ordinary functions, Previous: Internals, Up: Internals [Contents][Index]
Next: Generic functions, Previous: Special variables, Up: Internals [Contents][Index]
Previous: Ordinary functions, Up: Internals [Contents][Index]
Previous: Definitions, Up: The websocket-driver Reference Manual [Contents][Index]
Jump to: | (
A C E F G H I K M O P Q R S U V W |
---|
Jump to: | (
A C E F G H I K M O P Q R S U V W |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
Jump to: | +
A H K M P Q R S U V W |
---|
Jump to: | +
A H K M P Q R S U V W |
---|
Jump to: | C D F M P S U W |
---|
Jump to: | C D F M P S U W |
---|