Last active
November 6, 2017 15:12
-
-
Save juniorz/30790e8148f339f7c430bf264cf236e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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