Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the trivial-ws Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 06:04:58 2022 GMT+0.
Next: Systems, Previous: The trivial-ws Reference Manual, Up: The trivial-ws Reference Manual [Contents][Index]
Trivial WebSockets, built on top of Hunchensocket for the server and websocket-driver for the client.
Here's a simple echo server:
(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:
(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.
Copyright (c) 2016 Fernando Borretti
Licensed under the MIT License.
Next: Modules, Previous: Introduction, Up: The trivial-ws Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
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).
Next: Files, Previous: Systems, Up: The trivial-ws Reference Manual [Contents][Index]
Modules are listed depth-first from the system components tree.
Next: Packages, Previous: Modules, Up: The trivial-ws Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: trivial-ws/src/server.lisp, Previous: Lisp, Up: Lisp [Contents][Index]
trivial-ws (system).
Previous: trivial-ws/trivial-ws.asd, Up: Lisp [Contents][Index]
src (module).
Next: Definitions, Previous: Files, Up: The trivial-ws Reference Manual [Contents][Index]
Packages are listed by definition order.
Trivial WebSockets.
common-lisp.
Next: Indexes, Previous: Packages, Up: The trivial-ws 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: Ordinary functions, Previous: Public Interface, Up: Public Interface [Contents][Index]
Next: Standalone methods, Previous: Special variables, Up: Public Interface [Contents][Index]
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.
Next: Classes, Previous: Ordinary functions, Up: Public Interface [Contents][Index]
Previous: Standalone methods, Up: Public Interface [Contents][Index]
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.
Previous: Public Interface, Up: Definitions [Contents][Index]
Previous: Definitions, Up: The trivial-ws Reference Manual [Contents][Index]
Jump to: | C F G M N O S T |
---|
Jump to: | C F G M N O S T |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
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 |
---|