XMPP Core Functions
(require xmpp/core) | package: XMPP |
This package implements core elements required by other higher-level XMPP packages.
A JID consists of a localpart, a domainpart and a resourcepart, in that order. The localpart is optional and if present, it must precede the domainpart and is separated from it by an @ sign. Likewise, the resourcepart is also optional, follows the domainpart and is separated from it by a / (slash) character. A valid JID always has at least a domainpart.
procedure
(invalid-jid) → (jid?)
This is mainly useful when populating other data structures that require jid values, before we are able to obtain a valid JID from the user.
procedure
(valid-jid? jid) → (boolean?)
jid : jid?
> (valid-jid? (jid "user" "example.net" "laptop")) #t
> (valid-jid? (invalid-jid)) #f
> (bare-jid (jid "user" "example.net" "laptop")) (jid "user" "example.net" "")
procedure
(bare-jid-equal? jid0 jid1) → (boolean?)
jid0 : jid? jid1 : jid?
To compare two full JIDs for equality, use equal?.
> (equal? (jid "user" "example.net" "laptop") (jid "user" "example.net" "workstation")) #f
> (bare-jid-equal? (jid "user" "example.net" "laptop") (jid "user" "example.net" "workstation")) #t
> (bare-jid-equal? (jid "user" "example.net" "laptop") (jid "user" "example.com" "laptop")) #f
procedure
(jid/string? v) → (boolean?)
v : any/c
> (jid/string? (jid "user" "example.net" "laptop")) #t
> (jid/string? (invalid-jid)) #t
> (jid/string? "user@example.net/laptop") #t
> (jid/string? "") #t
> (jid/string? 33) #f
procedure
(jid->string jid) → (string?)
jid : jid?
> (jid->string (jid "user" "example.net" "resource")) "user@example.net/resource"
procedure
(jid→string jid) → (string?)
jid : jid?
procedure
(jid/string->string v) → (string?)
v : (or/c jid? string?)
This can be used to provide some flexibility when accepting inputs into procedures requiring JIDs as strings.
procedure
(jid/string→string v) → (string?)
v : (or/c jid? string?)
procedure
(string->jid str) → (jid?)
str : (and/c string? non-empty-string?)
> (string->jid "user@example.net/resource") (jid "user" "example.net" "resource")
procedure
(string→jid str) → (jid?)
str : (and/c string? non-empty-string?)
struct
(struct xmpp-connection ( host port jid passwd i-port o-port custodian buffer encryption)) host : string? port : port-number? jid : jid? passwd : string? i-port : input-port? o-port : output-port? custodian : custodian? buffer : (listof xexpr/c) encryption : symbol?