Skip to content

Instantly share code, notes, and snippets.

@juniorz
Last active November 6, 2017 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juniorz/30790e8148f339f7c430bf264cf236e8 to your computer and use it in GitHub Desktop.
Save juniorz/30790e8148f339f7c430bf264cf236e8 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/coyim/coyim/xmpp"
)
func main() {
//TODO: this nil will crash. You need to setup a verifier
df := xmpp.DialerFactory(nil)
df.SetJID("USER@SERVER")
df.SetPassword("PASSWORD")
conn, err := df.Dial() // Why not Dial(user, password) ?
if err != nil {
panic(err)
}
defer conn.Close()
//Need to process stanzas otherwise I/Q are not responded to their respective chan
go func() {
for {
s, err := conn.Next()
if err != nil {
panic(err)
}
fmt.Printf("- (from Next) %#v\n", s)
}
}()
rosterChan, _, err := conn.RequestRoster()
for s := range rosterChan {
fmt.Printf("- %s => %#v\n", s.Name.Local, s.Value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment