summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go/main.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/go/main.go b/go/main.go
index 18f2105..8bfb1fa 100644
--- a/go/main.go
+++ b/go/main.go
@@ -79,6 +79,7 @@ func (l *Limox) buttonCallback() {
switch l.State {
case Disconnected:
log.Println("Starting connection establishment")
+ go xmpp(l.JidEditor.Text(), l.PwdEditor.Text())
l.State = Connecting
case Connecting:
log.Println("Aborted connection establishment")
@@ -89,6 +90,35 @@ func (l *Limox) buttonCallback() {
}
}
+func xmpp(jid string, pwd string) {
+ log.Printf("JID: '%s' PWD: '%s'\n", jid, pwd)
+ log.Printf("Domain: '%s'\n", domainpart(jid))
+}
+
+// domainpart extracts the domain name from a JID / XMPP address. See
+// https://datatracker.ietf.org/doc/html/rfc7622#section-3.2 for details.
+func domainpart(jid string) string {
+ list := []rune(jid)
+
+ for i, v := range(list) {
+ if v == '/' {
+ log.Printf("Index of / rune: %d\n", i)
+ list = list[:i]
+ break
+ }
+ }
+
+ for i, v := range(list) {
+ if v == '@' {
+ log.Printf("Index of @ rune: %d\n", i)
+ list = list[i+1:]
+ break
+ }
+ }
+
+ return string(list)
+}
+
func (l *Limox) draw(e system.FrameEvent) {
gtx := layout.NewContext(&l.Operations, e)