69 lines
2.1 KiB
Racket
69 lines
2.1 KiB
Racket
#lang syndicate
|
|
|
|
(provide (struct-out ircd-listener)
|
|
(struct-out ircd-motd)
|
|
|
|
(struct-out claim)
|
|
(struct-out decision)
|
|
|
|
(struct-out ircd-nick)
|
|
(struct-out ircd-connection-info)
|
|
(struct-out ircd-channel)
|
|
(struct-out ircd-channel-member)
|
|
(struct-out ircd-channel-topic)
|
|
(struct-out ircd-channel-user-count)
|
|
|
|
(struct-out ircd-action)
|
|
(struct-out ircd-event)
|
|
|
|
(struct-out ircd-credentials)
|
|
|
|
lookup-nick)
|
|
|
|
;; A Connection is a TcpAddress
|
|
|
|
;;---------------------------------------------------------------------------
|
|
;; Configuration
|
|
|
|
;; (ircd-listener PortNumber) - causes TCP connections to be accepted on this port
|
|
(assertion-struct ircd-listener (port))
|
|
|
|
;; (ircd-motd (Listof String)) - Message Of The Day text
|
|
(assertion-struct ircd-motd (lines))
|
|
|
|
;;---------------------------------------------------------------------------
|
|
;; Affine resources
|
|
|
|
;; (claim Any NonFalse) -- any number of these. Decider picks a claimant
|
|
(assertion-struct claim (resource claimant))
|
|
|
|
;; (decision Any NonFalse) -- zero or one of these for a given resource.
|
|
(assertion-struct decision (resource resource-holder))
|
|
|
|
;;---------------------------------------------------------------------------
|
|
;; IRC protocol
|
|
|
|
;; (ircd-nick String) - a unique resource
|
|
(assertion-struct ircd-nick (name))
|
|
|
|
;; (ircd-connection-info Connection String IRCUser) -- mapping: nick <--> conn + userinfo
|
|
(assertion-struct ircd-connection-info (conn nick user))
|
|
|
|
(assertion-struct ircd-channel (channel))
|
|
(assertion-struct ircd-channel-member (channel conn))
|
|
(assertion-struct ircd-channel-topic (channel topic))
|
|
(assertion-struct ircd-channel-user-count (channel count))
|
|
|
|
(message-struct ircd-action (conn message))
|
|
(message-struct ircd-event (conn message))
|
|
|
|
(assertion-struct ircd-credentials (nick user password valid?))
|
|
|
|
;;---------------------------------------------------------------------------
|
|
;; Application: chatroom model
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
(define (lookup-nick conn)
|
|
(immediate-query [query-value #f (ircd-connection-info conn $N _) N]))
|