sigildocs

(sigil irc cap-negotiation)

(sigil irc cap-negotiation) - CAP negotiation state machines

CAP negotiation is the IRCv3 handshake by which client and server agree on a set of optional capabilities. The wire dance:

C: CAP LS 302
S: CAP * LS * :sasl=PLAIN,EXTERNAL message-tags ...
S: CAP * LS :server-time chghost ...
C: CAP REQ :sasl message-tags server-time
S: CAP * ACK :sasl message-tags server-time      (or NAK)
C: AUTHENTICATE PLAIN              (if SASL was negotiated)
...
C: CAP END

This module provides two state machines, one per role. Both follow the same shape: a state value + an advance function that takes an incoming irc-message and returns (values new-state outbound) where outbound is a list of wire-format strings to send.

The state machine is a pure value — the consumer owns I/O and fiber structure. This matches the protocol-only contract of sigil-irc.

Exports

Construct a cap-client-state struct.

Test if a value is a cap-client-state struct.

Get the phase field of a cap-client-state struct.

Get the desired field of a cap-client-state struct.

Get the server-caps field of a cap-client-state struct.

Get the requested field of a cap-client-state struct.

Get the acked field of a cap-client-state struct.

Get the nakked field of a cap-client-state struct.

Set the phase field of a cap-client-state struct.

Set the server-caps field of a cap-client-state struct.

Set the requested field of a cap-client-state struct.

Set the acked field of a cap-client-state struct.

Set the nakked field of a cap-client-state struct.

Build a client-side CAP state with a list of desired capability names. After construction, call cap-client-start to get the opening CAP LS line, then feed each incoming CAP / numeric reply through cap-client-advance.

Begin negotiation. Returns the line to send (CAP LS 302\r\n). Transitions phase to 'ls.

Process one incoming message and advance the state. Returns a list of wire-format strings to send (possibly empty). Messages that aren't CAP-related are simply ignored.

Construct a cap-server-state struct.

Test if a value is a cap-server-state struct.

Get the phase field of a cap-server-state struct.

Get the server-name field of a cap-server-state struct.

Get the supported field of a cap-server-state struct.

Get the enabled field of a cap-server-state struct.

Get the cap-302 field of a cap-server-state struct.

Set the phase field of a cap-server-state struct.

Set the enabled field of a cap-server-state struct.

Set the cap-302 field of a cap-server-state struct.

Construct a server-side CAP state. supported is a list of cap records. server-name appears in reply prefixes (typically the server's domain).

Process one incoming CAP message from the client and advance the state. Returns a list of wire-format strings to send back. Non-CAP messages are ignored. The client's current nick (or #f if not yet known, in which case * is used in replies) is passed in so the reply prefix matches the spec.

(No description)

(No description)