This is the trivial-ws Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:58:01 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
trivial-ws
Trivial WebSockets.
Fernando Borretti <eudoxiahp@gmail.com>
Fernando Borretti <eudoxiahp@gmail.com>
(GIT git@github.com:ceramic/trivial-ws.git)
MIT
# trivial-ws
Trivial WebSockets, built on top of [Hunchensocket][hs] for the server and
[websocket-driver][driver] for the client.
# Usage
Here’s a simple echo server:
~~~lisp
(defvar *server*
(trivial-ws:make-server
:on-connect #’(lambda (server)
(format t "Connected~%"))
:on-disconnect #’(lambda (server)
(format t "Disconnected~%"))
:on-message #’(lambda (server message)
(format t "Received: ~A~%" message)
(trivial-ws:send (first (trivial-ws:clients server))
message))))
~~~
Then start it:
~~~lisp
(defvar *handler* (trivial-ws:start *server* 4040))
~~~
Then go to http://www.websocket.org/echo.html and change the server to
‘ws://localhost:4040/‘ and try it out.
You can stop it with ‘(trivial-ws:stop *handler*)‘.
Inside the callbacks you can use two functions: ‘(trivial-ws:clients server)‘
will return the list of connected clients, and ‘(trivial-ws:send client
"string")‘ will send a message to a selected client.
# License
Copyright (c) 2016 Fernando Borretti
Licensed under the MIT License.
[hs]: https://github.com/capitaomorte/hunchensocket
[driver]: https://github.com/fukamachi/websocket-driver
0.1
hunchensocket
(system).
src
(module).
Modules are listed depth-first from the system components tree.
Files are sorted by type and then listed depth-first from the systems components trees.
trivial-ws/src/server.lisp
src
(module).
+default-address+
(special variable).
+default-timeout+
(special variable).
client-connected
(method).
client-disconnected
(method).
clients
(function).
make-server
(function).
send
(function).
server
(class).
start
(function).
stop
(function).
text-message-received
(method).
client
(class).
name
(reader method).
on-connect
(reader method).
on-disconnect
(reader method).
on-message
(reader method).
Packages are listed by definition order.
trivial-ws
Trivial WebSockets.
common-lisp
.
+default-address+
(special variable).
+default-timeout+
(special variable).
clients
(function).
make-server
(function).
send
(function).
server
(class).
start
(function).
stop
(function).
client
(class).
name
(generic reader).
on-connect
(generic reader).
on-disconnect
(generic reader).
on-message
(generic reader).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Return a list of server clients.
Create a server given the three callback functions.
Send a string of text to the client.
Start the server. Returns a handler object.
Stops a server handler.
websocket-resource
.
Initarg | Value |
---|---|
:client-class | (quote client) |
The function that is called when a client connects.
function
(function (lambda (trivial-ws:server) (declare (ignore trivial-ws:server)) nil))
:on-connect
This slot is read-only.
The function that is called when a client disconnects.
function
(function (lambda (trivial-ws:server) (declare (ignore trivial-ws:server)) nil))
:on-disconnect
This slot is read-only.
The function that’s called when a client sends a message.
function
(function (lambda (trivial-ws:server trivial-ws::message) (declare (ignore trivial-ws:server trivial-ws::message)) nil))
:on-message
This slot is read-only.
Jump to: | C F G M N O S T |
---|
Jump to: | C F G M N O S T |
---|
Jump to: | +
N O S |
---|
Jump to: | +
N O S |
---|
Jump to: | C F M P S T |
---|
Jump to: | C F M P S T |
---|