The trivial-ws Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The trivial-ws Reference Manual

This is the trivial-ws Reference Manual, version 0.1, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:28:07 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

trivial-ws

Trivial WebSockets, built on top of Hunchensocket for the server and websocket-driver for the client.

Usage

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.

License

Copyright (c) 2016 Fernando Borretti

Licensed under the MIT License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 trivial-ws

Maintainer

Fernando Borretti <eudoxiahp@gmail.com>

Author

Fernando Borretti <eudoxiahp@gmail.com>

Home Page

https://github.com/ceramic/trivial-ws

Source Control

(:git "git@github.com:ceramic/trivial-ws.git")

Bug Tracker

https://github.com/ceramic/trivial-ws/issues

License

MIT

Description

Trivial WebSockets.

Long Description

# 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

Version

0.1

Dependency

hunchensocket

Source

trivial-ws.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 trivial-ws/src

Parent

trivial-ws (system)

Location

src/

Component

server.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 trivial-ws.asd

Location

trivial-ws.asd

Systems

trivial-ws (system)


Previous: , Up: Lisp files   [Contents][Index]

4.1.2 trivial-ws/src/server.lisp

Parent

src (module)

Location

src/server.lisp

Packages

trivial-ws

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

5.1 trivial-ws

Trivial WebSockets.

Source

server.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Special variables

Special Variable: +default-address+
Package

trivial-ws

Source

server.lisp (file)

Special Variable: +default-timeout+
Package

trivial-ws

Source

server.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Functions

Function: clients SERVER

Return a list of server clients.

Package

trivial-ws

Source

server.lisp (file)

Function: make-server &key ON-CONNECT ON-DISCONNECT ON-MESSAGE

Create a server given the three callback functions.

Package

trivial-ws

Source

server.lisp (file)

Function: send CLIENT STRING

Send a string of text to the client.

Package

trivial-ws

Source

server.lisp (file)

Function: start SERVER PORT &key ADDRESS TIMEOUT

Start the server. Returns a handler object.

Package

trivial-ws

Source

server.lisp (file)

Function: stop HANDLER

Stops a server handler.

Package

trivial-ws

Source

server.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Classes

Class: server ()
Package

trivial-ws

Source

server.lisp (file)

Direct superclasses

websocket-resource (class)

Direct methods
Direct slots
Slot: on-connect

The function that is called when a client connects.

Type

function

Initargs

:on-connect

Initform

(function (lambda (trivial-ws:server) (declare (ignore trivial-ws:server)) nil))

Readers

on-connect (generic function)

Slot: on-disconnect

The function that is called when a client disconnects.

Type

function

Initargs

:on-disconnect

Initform

(function (lambda (trivial-ws:server) (declare (ignore trivial-ws:server)) nil))

Readers

on-disconnect (generic function)

Slot: on-message

The function that’s called when a client sends a message.

Type

function

Initargs

:on-message

Initform

(function (lambda (trivial-ws:server trivial-ws::message) (declare (ignore trivial-ws:server trivial-ws::message)) nil))

Readers

on-message (generic function)

Direct Default Initargs
InitargValue
:client-class(quote trivial-ws::client)

Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Generic functions

Generic Function: name OBJECT
Package

trivial-ws

Methods
Method: name (CLIENT client)

automatically generated reader method

Source

server.lisp (file)

Generic Function: on-connect OBJECT
Package

trivial-ws

Methods
Method: on-connect (SERVER server)

The function that is called when a client connects.

Source

server.lisp (file)

Generic Function: on-disconnect OBJECT
Package

trivial-ws

Methods
Method: on-disconnect (SERVER server)

The function that is called when a client disconnects.

Source

server.lisp (file)

Generic Function: on-message OBJECT
Package

trivial-ws

Methods
Method: on-message (SERVER server)

The function that’s called when a client sends a message.

Source

server.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Classes

Class: client ()
Package

trivial-ws

Source

server.lisp (file)

Direct superclasses

websocket-client (class)

Direct methods

name (method)

Direct slots
Slot: name
Initargs

:user-agent

Readers

name (generic function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M   T  
Index Entry  Section

F
File, Lisp, trivial-ws.asd: The trivial-ws<dot>asd file
File, Lisp, trivial-ws/src/server.lisp: The trivial-ws/src/server<dot>lisp file

L
Lisp File, trivial-ws.asd: The trivial-ws<dot>asd file
Lisp File, trivial-ws/src/server.lisp: The trivial-ws/src/server<dot>lisp file

M
Module, trivial-ws/src: The trivial-ws/src module

T
trivial-ws.asd: The trivial-ws<dot>asd file
trivial-ws/src: The trivial-ws/src module
trivial-ws/src/server.lisp: The trivial-ws/src/server<dot>lisp file

Jump to:   F   L   M   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   F   G   M   N   O   S  
Index Entry  Section

C
clients: Exported functions

F
Function, clients: Exported functions
Function, make-server: Exported functions
Function, send: Exported functions
Function, start: Exported functions
Function, stop: Exported functions

G
Generic Function, name: Internal generic functions
Generic Function, on-connect: Internal generic functions
Generic Function, on-disconnect: Internal generic functions
Generic Function, on-message: Internal generic functions

M
make-server: Exported functions
Method, name: Internal generic functions
Method, on-connect: Internal generic functions
Method, on-disconnect: Internal generic functions
Method, on-message: Internal generic functions

N
name: Internal generic functions
name: Internal generic functions

O
on-connect: Internal generic functions
on-connect: Internal generic functions
on-disconnect: Internal generic functions
on-disconnect: Internal generic functions
on-message: Internal generic functions
on-message: Internal generic functions

S
send: Exported functions
start: Exported functions
stop: Exported functions

Jump to:   C   F   G   M   N   O   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
N   O   S  
Index Entry  Section

+
+default-address+: Exported special variables
+default-timeout+: Exported special variables

N
name: Internal classes

O
on-connect: Exported classes
on-disconnect: Exported classes
on-message: Exported classes

S
Slot, name: Internal classes
Slot, on-connect: Exported classes
Slot, on-disconnect: Exported classes
Slot, on-message: Exported classes
Special Variable, +default-address+: Exported special variables
Special Variable, +default-timeout+: Exported special variables

Jump to:   +  
N   O   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S   T  
Index Entry  Section

C
Class, client: Internal classes
Class, server: Exported classes
client: Internal classes

P
Package, trivial-ws: The trivial-ws package

S
server: Exported classes
System, trivial-ws: The trivial-ws system

T
trivial-ws: The trivial-ws system
trivial-ws: The trivial-ws package

Jump to:   C   P   S   T