lichat serverlib
1.0.0Tools to help build a server using the lichat protocol.
Table of Contents
About Lichat-Serverlib
This is an implementation of the server-side protocol part of the Lichat protocol. It provides an extensible, transport-agnostic implementation that can be used to base a functional server on. All that the real server needs to take care of is the underlying connection establishment and reading.
You do not need this library if you are looking to implement a client. You don't need it if you're looking to implement a server either, but it will take care of a large part of the implementation tasks for you if you do use it.
Implementing an Overarching Server
In order to implement an actual server, you will want to do the following:
- Subclass at least
serverandconnection. - Provide functions to start a listener on a server instance.
- For each client that connects, create a
connectionobject. - Provide functions to repeatedly read updates from a
connectionand send them toprocess. - Supply an after method on
teardown-connectionthat closes the connection to the client properly. - Provide a primary method for
sendspecialised on yourconnectionsubclass that handles the actual wire transmission of an update. - Handle potential synchronisation or mutual-exclusion issues to users, channels, profiles, and connections on the server if your server is multi-threaded.
For a simple illustrative example, see the lichat-tcp-server.
Also See
- lichat-protocol The Lichat protocol specification.
- lichat-tcp-server A basic, threaded, TCP-based implementation of a Lichat server.
- lichat-tcp-client A basic, threaded, TCP-based implementation of a Lichat client.
- LionChat A Qt GUI client for a TCP server.
System Information
Definition Index
-
LICHAT-SERVERLIB
- ORG.SHIRAKUMO.LICHAT.SERVERLIB
No documentation provided.-
EXTERNAL SPECIAL-VARIABLE *ALLOWED-EMOTE-CONTENT-TYPES*
No documentation provided. -
EXTERNAL CLASS BACKLOGGED-CHANNEL
No documentation provided. -
EXTERNAL CLASS CHANNEL
A server-side channel object. See LICHAT-PROTOCOL:CHANNEL See TIMEOUTABLE
-
EXTERNAL CLASS CONNECTION
The representation of a client connection. See SERVER See LAST-UPDATE See LICHAT-PROTOCOL:CONNECTION
-
EXTERNAL CLASS FLOOD-PROTECTED-CONNECTION
A connection with basic time-frame flood-protection. See CONNECTION See LAST-FRAME See FRAME-COUNT
-
EXTERNAL CLASS FLOOD-PROTECTED-SERVER
A server with basic time-frame flood-protection. See SERVER See FLOOD-FRAME See FLOOD-LIMIT
-
EXTERNAL CLASS PROFILE
A server-side profile object See LICHAT-PROTOCOL:PROFILE See TIMEOUTABLE
-
EXTERNAL CLASS SERVER
An object representation of the server. See USER See USERS See PROFILES See CHANNELS See IDLE-TIMEOUT
-
EXTERNAL CLASS TIMEOUTABLE
Superclass for objects that can be invalidated through a timeout. See TIMEOUT See START-TIMEOUT See RESET-TIMEOUT See ALIVE-P
-
EXTERNAL CLASS USER
A server-side user object See LICHAT-PROTOCOL:USER
-
EXTERNAL CONDITION FAILURE-CONDITION
Wrapper condition to carry a failure update. See FAILURE-TYPE See FAILURE-ARGS See FAIL!
-
EXTERNAL FUNCTION ADD-EMOTE
- PATHNAME
No documentation provided. -
EXTERNAL FUNCTION ADD-EMOTES
- DIRECTORY
No documentation provided. -
EXTERNAL FUNCTION CHECK-CHANNEL
- CONNECTION
- UPDATE
- &OPTIONAL
- MUST-BE-IN
Checks whether the CHANNEL field is a valid channel. If the channel does not exist, a FAILURE-CONDITION for a LICHAT-PROTOCOL:NO-SUCH-CHANNEL failure is signalled. If it does exist, but the user is not a part of it, a FAILURE CONDITION for a LICHAT-PROTOCOL:NOT-IN-CHANNEL failure is signalled. Otherwise, the corresponding channel object is returned. This is in accordance with §5.1.5 §5.4.2 §5.4.3 §5.4.4 §5.4.5 See LICHAT-PROTOCOL:NO-SUCH-CHANNEL See LICHAT-PROTOCOL:NOT-IN-CHANNEL See FIND-CHANNEL
-
EXTERNAL FUNCTION CHECK-CHANNELNAME
- CONNECTION
- UPDATE
Checks whether the CHANNEL field has a valid, unused name. If the channel name is malformed, a FAILURE-CONDITION for a LICHAT-PROTOCOL:BAD-NAME failure is signalled. If it is valid, but a channel of that name already exists, a FAILURE- CONDITION for a LICHAT-PROTOCOL:CHANNELNAME-TAKEN failure is signalled. This is in accordance with §5.1.3 §5.3.2 See LICHAT-PROTOCOL:BAD-NAME See LICHAT-PROTOCOL:CHANNELNAME-TAKEN See FIND-CHANNEL See LICHAT-PROTOCOL:CHANNELNAME-P
-
EXTERNAL FUNCTION CHECK-FROM
- CONNECTION
- UPDATE
Checks whether the FROM field matches the update. If it is not, a FAILURE-CONDITION for a LICHAT-PROTOCOL: USERNAME-MISMATCH failure is signalled. If it is, the corresponding user object is returned. This is in accordance with §5.1.4 See LICHAT-PROTOCOL:USERNAME-MISMATCH See FIND-USER
-
EXTERNAL FUNCTION CHECK-PERMITTED
- CONNECTION
- UPDATE
- &OPTIONAL
- CHANNEL
Checks whether the given update is permitted. If it is not, a FAILURE-CONDITION for a LICHAT-PROTOCOL: INSUFFICIENT-PERMISSIONS failure is signalled. This is in accordance with §5.1.7 See PERMITTED See LICHAT-PROTOCOL:INSUFFICIENT-PERMISSIONS
-
EXTERNAL FUNCTION CHECK-TARGET
- CONNECTION
- UPDATE
Checks whether the TARGET field is a valid user. If it is not, a FAILURE-CONDITION for a LICHAT-PROTOCOL: NO-SUCH-USER failure is signalled. If it is, the corresponding user object is returned. This is in accordance with §5.1.6 See LICHAT-PROTOCOL:NO-SUCH-USER See FIND-USER
-
EXTERNAL FUNCTION COERCE-CHANNELNAME
- NAME-ISH
Attempt to coerce the name-ish to a channel name. Valid types are: LICHAT-PROTOCOL:CHANNEL-UPDATE LICHAT-PROTOCOL:CHANNEL STRING
-
EXTERNAL FUNCTION COERCE-USERNAME
- NAME-ISH
Attempt to coerce the name-ish to a user name. Valid types are: LICHAT-PROTOCOL:UPDATE LICHAT-PROTOCOL:USER STRING
-
EXTERNAL FUNCTION EMOTE
- NAME
No documentation provided. -
EXTERNAL FUNCTION (SETF EMOTE)
- EMOTE
- NAME
No documentation provided. -
EXTERNAL FUNCTION FAIL!
- TYPE-ISH
- &REST
- INITARGS
Signal a FAILURE-CONDITION that carries the designated failure and sends it off to the client. See FAILURE-CONDITION
-
EXTERNAL FUNCTION PERMITTED
- ACTION
- CHANNEL
- USER
Returns true if the action on the channel by the user is permitted. Action should be the class-name of an update. See RULE-PERMITTED See LICHAT-PROTOCOL:PERMISSIONS
-
EXTERNAL FUNCTION PREP-PERMS
- REGISTRANT
- PERMS
Prepare the list of permissions rule for the registrant.
-
EXTERNAL FUNCTION REMOVE-EMOTE
- NAME
No documentation provided. -
EXTERNAL FUNCTION RULE-PERMITTED
- RULE
- NAME
Checks whether the given rule allows the user of the given name access. The rule evaluation is implemented according to §2.5
-
EXTERNAL FUNCTION SEND!
- CONNECTION
- TYPE-ISH
- &REST
- INITARGS
Convenience function to send an update to a connection. Specifically, this will: * Coerce the type-ish to a protocol type by looking the symbol up in the lichat-protocol package. * Add the :FROM initarg if it does not yet exist by using the connection's server's name. See SEND
-
EXTERNAL GENERIC-FUNCTION ALIVE-P
- TIMEOUTABLE
Returns T if the object is still considered to be alive.
-
EXTERNAL GENERIC-FUNCTION ALLOWED-CONTENT-TYPES
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF ALLOWED-CONTENT-TYPES)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION BACKLOG
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF BACKLOG)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CHANNELS
- OBJECT
Accessor to the hash-table of channels that exist on the server. See SERVER
-
EXTERNAL GENERIC-FUNCTION (SETF CHANNELS)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CHECK-CONNECTION-TIMEOUT
- CONNECTION
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CREATE
- REGISTRANT
- NAME
- SERVER
Creates an appropriate channel object for the registrant on the server. If NAME is NIL, a random ID with an @ prefix is chosen that does not already exist on the server. If NAME is STRING= to the name of the server, a primary channel is created. Otherwise a regular channel is created. This is in accordance to §2.4 Note that this will /not/ check whether a channel of the given name already exists and will instead just replace it. See PREP-PERMS See LICHAT-PROTOCOL:CREATE See MAKE-CHANNEL See FIND-CHANNEL See LICHAT-PROTOCOL:*DEFAULT-ANONYMOUS-CHANNEL-PERMISSIONS* See LICHAT-PROTOCOL:*DEFAULT-PRIMARY-CHANNEL-PERMISSIONS* See LICHAT-PROTOCOL:*DEFAULT-REGULAR-CHANNEL-PERMISSIONS*
-
EXTERNAL GENERIC-FUNCTION DEFAULT-READ-LIMIT
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF DEFAULT-READ-LIMIT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FAILURE-ARGS
- CONDITION
The initargs of the failure update that should be constructed to relay this error to the client. See FAILURE-CONDITION
-
EXTERNAL GENERIC-FUNCTION FAILURE-TYPE
- CONDITION
The type of the failure update that should be constructed to relay this error to the client. See FAILURE-CONDITION
-
EXTERNAL GENERIC-FUNCTION FIND-CHANNEL
- NAME
- SERVER
Accesses a channel by the given name-ish on the server. See COERCE-CHANNELNAME See CHANNELS See REMOVE-CHANNEL
-
EXTERNAL GENERIC-FUNCTION (SETF FIND-CHANNEL)
- CHANNEL
- NAME
- SERVER
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FIND-PROFILE
- NAME
- SERVER
Accesses a profile by the given name-ish on the server. See COERCE-USERNAME See PROFILES See REMOVE-PROFILE
-
EXTERNAL GENERIC-FUNCTION (SETF FIND-PROFILE)
- PROFILE
- NAME
- SERVER
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FIND-USER
- NAME
- SERVER
Accesses a user by the given name-ish on the server. See COERCE-USERNAME See USERS See REMOVE-USER
-
EXTERNAL GENERIC-FUNCTION (SETF FIND-USER)
- USER
- NAME
- SERVER
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FLOOD-FRAME
- OBJECT
Accessor to the number of seconds for which a flood frame lasts. See FLOOD-PROTECTED-SERVER
-
EXTERNAL GENERIC-FUNCTION (SETF FLOOD-FRAME)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FLOOD-LIMIT
- OBJECT
Accessor to the number of updates that can be received within a frame before the connection is limited. See FLOOD-PROTECTED-SERVER
-
EXTERNAL GENERIC-FUNCTION (SETF FLOOD-LIMIT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FRAME-COUNT
- OBJECT
Accessor to the number of updates that were processed within the last frame. See FLOOD-PROTECTED-CONNECTION
-
EXTERNAL GENERIC-FUNCTION (SETF FRAME-COUNT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION IDLE-TIMEOUT
- OBJECT
Accessor to the number of seconds a connection can be idle before it is considered timed out. See SERVER
-
EXTERNAL GENERIC-FUNCTION (SETF IDLE-TIMEOUT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION INIT-CONNECTION
- CONNECTION
- UPDATE
Registers the connection on the server and prepares it for use. This corresponds to §4.1.8 to §4.1.12 with the additional act that a related profile's timeout is reset, if such a profile is found. See RESET-TIMEOUT
-
EXTERNAL GENERIC-FUNCTION JOIN
- CHANNEL
- USER
- &OPTIONAL
- ID
Join a user to a channel. Note that this will /not/ check whether the user is already in the channel or not and will just join them regardless. A JOIN update is sent to all channel inhabitants, with the given ID, or a fresh one if none is given. The channel's timeout is reset. See LICHAT-PROTOCOL:JOIN See LICHAT-PROTOCOL:NEXT-ID See RESET-TIMEOUT
-
EXTERNAL GENERIC-FUNCTION JOIN-TIMES
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF JOIN-TIMES)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LAST-FRAME
- OBJECT
Accessor to the last frame number the connection handled. See FLOOD-PROTECTED-CONNECTION
-
EXTERNAL GENERIC-FUNCTION (SETF LAST-FRAME)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LAST-UPDATE
- OBJECT
Accessor to the universal-time of when the last update was processed on the connection. See CONNECTION
-
EXTERNAL GENERIC-FUNCTION (SETF LAST-UPDATE)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LEAVE
- CHANNEL
- USER
- &KEY
- ID
- NOTIFY-SELF
Leave a user from a channel. Note that this will /not/ check whether the user actually is in the channel or not and will just leave them regardless. A LEAVE update is sent to all channel inhabitants, with the given ID, or a fresh one if none is given. If no users remain, the channel's timeout is started. If NOTIFY-SELF is NIL, the LEAVE update is sent to every channel inhabitant other than the user leaving. Otherwise, the update is sent to everyone including the one leaving. See LICHAT-PROTOCOL:LEAVE See LICHAT-PROTOCOL:NEXT-ID See START-TIMEOUT
-
EXTERNAL GENERIC-FUNCTION LIST-CHANNELS
- SERVER
Return a fresh list of all known channel objects for the server. See CHANNEL
-
EXTERNAL GENERIC-FUNCTION LIST-PROFILES
- SERVER
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LIST-USERS
- SERVER
Return a fresh list of all known profile objects for the server. See PROFILE
-
EXTERNAL GENERIC-FUNCTION MAKE-CHANNEL
- SERVER
- &REST
- INITARGS
Construct an appropriate channel object for the server. See CHANNEL
-
EXTERNAL GENERIC-FUNCTION MAKE-CONNECTION
- SERVER
- &REST
- INITARGS
Construct an appropriate connection object for the server. See CONNECTION
-
EXTERNAL GENERIC-FUNCTION MAKE-PROFILE
- SERVER
- &REST
- INITARGS
Construct an appropriate user object for the server. See PROFILE
-
EXTERNAL GENERIC-FUNCTION MAKE-USER
- SERVER
- &REST
- INITARGS
Construct an appropriate user object for the server. See USER
-
EXTERNAL GENERIC-FUNCTION PASS-FLOOD-GATE
- CONNECTION
- UPDATE
Updates flood information for the connection and returns whether the connection is fine or not. See FLOOD-PROTECTED-CONNECTION See PROCESS
-
EXTERNAL GENERIC-FUNCTION PASSWORD
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF PASSWORD)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION PASSWORD-VALID-P
- PROFILE
- PASSWORD
No documentation provided. -
EXTERNAL GENERIC-FUNCTION PROCESS
- CONNECTION
- STREAM
Process an update source on a connection. Sources that are accepted: * STREAM -- An update is read from the stream and sent off to PROCESS again. * LICHAT-PROTOCOL:UPDATE -- The update is handled accordingly. If an error of type FAILURE-CONDITION is signalled during the evaluation of non-around methods, the encapsulated failure update is sent to the connection. If an error of type LICHAT-PROTOCOL: PROTOCOL-CONDITION is signalled during the evaluation of non-around methods, an update of type LICHAT-PROTOCOL:FAILURE is sent to the connection. A CONTINUE restart is established around the method that can be used to respond with a generic LICHAT-PROTOCOL:UPDATE-FAILURE and return from the PROCESS method. This method will also take care to handle flooding and timeout recording for the connection. The overarching server must establish a restart called CLOSE- CONNECTION around the PROCESS method, or around all calls of it. When this restart is invoked, the server must close the underlying connection. See LICHAT-PROTOCOL:FROM-WIRE See LICHAT-PROTOCOL:PROTOCOL-CONDITION See LICHAT-PROTOCOL:UPDATE-FAILURE See FAILURE-CONDITION -
EXTERNAL GENERIC-FUNCTION PROFILES
- OBJECT
Accessor to the hash-table of profiles that exist on the server. See SERVER
-
EXTERNAL GENERIC-FUNCTION (SETF PROFILES)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION READ-LIMIT
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF READ-LIMIT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION REGISTER
- REGISTRANT
- PASSWORD
- SERVER
Register a user profile. Note that this will /not/ check whether the associated user actually exists on the server or not and will just create the profile regardless. See FIND-PROFILE See MAKE-PROFILE See LICHAT-PROTOCOL:REGISTER
-
EXTERNAL GENERIC-FUNCTION REMOVE-CHANNEL
- NAME
- SERVER
Removes the channel by the given name from the server. See COERCE-CHANNELNAME See CHANNELS See FIND-CHANNEL
-
EXTERNAL GENERIC-FUNCTION REMOVE-PROFILE
- NAME
- SERVER
Removes the profile by the given name-ish from the server. See COERCE-USERNAME See PROFILES See FIND-PROFILE
-
EXTERNAL GENERIC-FUNCTION REMOVE-USER
- NAME
- SERVER
Removes the user by the given name-ish from the server. See COERCE-USERNAME See USERS See FIND-USER
-
EXTERNAL GENERIC-FUNCTION RESET-TIMEOUT
- TIMEOUTABLE
Resets the timeout to never occur. See TIMEOUTABLE
-
EXTERNAL GENERIC-FUNCTION SEND
- OBJECT
- CONNECTION
Send an update to a place. Places that are accepted: * CONNECTION -- Directly sends the update over the wire. Note that the primary method for this must be implemented by the overarching server. * USER -- Relays the update to all connections of the user. * CHANNEL -- Relays the update to all users in the channel. This function has to be called in a regular interval by the overarching server. It will take care of handling connection timeouts and will close the connection in case of one. See CONNECTION See USER See CHANNEL -
EXTERNAL GENERIC-FUNCTION SERVER
- OBJECT
Accessor to the connection's server. See CONNECTION
-
EXTERNAL GENERIC-FUNCTION (SETF SERVER)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION START-TIMEOUT
- TIMEOUTABLE
Starts the timeout by setting the object's TIMEOUT slot to the correct time. See TIMEOUTABLE See LICHAT-PROTOCOL:LIFETIME
-
EXTERNAL GENERIC-FUNCTION TEARDOWN-CONNECTION
- CONNECTION
Removes and cleans up the connection on the server. This corresponds to §4.3.3 to §4.3.4 with the additional act that a related profile's timeout is started, if such a profile is found. See START-TIMEOUT
-
EXTERNAL GENERIC-FUNCTION TIMEOUT
- OBJECT
The universal-time by which the object will be invalidated, if any. See TIMEOUTABLE
-
EXTERNAL GENERIC-FUNCTION (SETF TIMEOUT)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION USERS
- OBJECT
Accessor to the hash-table of users that exist on the server. See SERVER
-
EXTERNAL GENERIC-FUNCTION (SETF USERS)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL MACRO DEFINE-UPDATE-HANDLER
- TYPE
- CONNECTION
- UPDATE
- &BODY
- BODY
Easy wrapper to define a handler method for an update on a connection. UPDATE is coerced to a symbol found in the LICHAT-PROTOCOL package. This creates a PROCESS method. See PROCESS