(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
cap-client-stateprocedureConstruct a cap-client-state struct.
cap-client-state?procedureTest if a value is a cap-client-state struct.
cap-client-state-phaseprocedureGet the phase field of a cap-client-state struct.
cap-client-state-desiredprocedureGet the desired field of a cap-client-state struct.
cap-client-state-server-capsprocedureGet the server-caps field of a cap-client-state struct.
cap-client-state-requestedprocedureGet the requested field of a cap-client-state struct.
cap-client-state-ackedprocedureGet the acked field of a cap-client-state struct.
cap-client-state-nakkedprocedureGet the nakked field of a cap-client-state struct.
set-cap-client-state-phase!procedureSet the phase field of a cap-client-state struct.
set-cap-client-state-server-caps!procedureSet the server-caps field of a cap-client-state struct.
set-cap-client-state-requested!procedureSet the requested field of a cap-client-state struct.
set-cap-client-state-acked!procedureSet the acked field of a cap-client-state struct.
set-cap-client-state-nakked!procedureSet the nakked field of a cap-client-state struct.
make-cap-client-statevariableBuild 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.
cap-client-startprocedureBegin negotiation. Returns the line to send (CAP LS 302\r\n). Transitions phase to 'ls.
cap-client-advanceprocedureProcess 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.
cap-server-stateprocedureConstruct a cap-server-state struct.
cap-server-state?procedureTest if a value is a cap-server-state struct.
cap-server-state-phaseprocedureGet the phase field of a cap-server-state struct.
cap-server-state-server-nameprocedureGet the server-name field of a cap-server-state struct.
cap-server-state-supportedprocedureGet the supported field of a cap-server-state struct.
cap-server-state-enabledprocedureGet the enabled field of a cap-server-state struct.
cap-server-state-cap-302procedureGet the cap-302 field of a cap-server-state struct.
set-cap-server-state-phase!procedureSet the phase field of a cap-server-state struct.
set-cap-server-state-enabled!procedureSet the enabled field of a cap-server-state struct.
set-cap-server-state-cap-302!procedureSet the cap-302 field of a cap-server-state struct.
make-cap-server-statevariableConstruct a server-side CAP state. supported is a list of cap records. server-name appears in reply prefixes (typically the server's domain).
cap-server-advancevariableProcess 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.
cap-client-state-done?variable(No description)
cap-server-state-done?variable(No description)