Simple chat server with group subscriptions and registration of the clients.
make compile
make test
make run
Configuration file is placed in sys.config
file. There are following configuration options enabled:
- port - TCP port used by khat server (default is 6667)
- acceptors - number of acceptor processes waiting for a TCP connection establishment
- inactivity_timeout - timeout (in seconds) after which the TCP connection is closed if client hasn't sent any messages or alive packets
When server is running you can connect to it via telnet:
telnet 127.0.0.1 6667
Messages starting with a \
character are special commands described in the commands section below. All other data sent from the client is broadcasted to all clients connected to the server.
When user is unregistered then messages can only be received but not sent.
\register\Client Name
Any messages sent to group Group Name
in the example below by any of the clients will be sent to the subscribed client.
\subscribe\Group Name
No more messages destined for this group will be sent to the client.
\unsubscribe\Group Name
Only clients subscribed to this group will receive this message.
\group=Group Name\Some message
If client isn't sending any messages then keepalive packets needs to be sent in order to remain connected to the server. If there's no data sent by the client within inactivity_timeout
seconds then the client will be disconnected from the server.
\alive\