Fix examples

This commit is contained in:
mattn 2014-09-17 12:35:47 +09:00
parent 748282a14a
commit f402673c8c
2 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"crypto/tls"
"github.com/mattn/go-gtk/gtk"
"github.com/mattn/go-xmpp"
"log"
@ -56,7 +57,7 @@ func main() {
dialog.AddButton(gtk.STOCK_OK, gtk.RESPONSE_OK)
dialog.AddButton(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
dialog.SetDefaultResponse(int(gtk.RESPONSE_OK))
dialog.SetDefaultResponse(gtk.RESPONSE_OK)
dialog.SetTransientFor(window)
dialog.ShowAll()
res := dialog.Run()
@ -67,6 +68,11 @@ func main() {
os.Exit(0)
}
xmpp.DefaultConfig = tls.Config {
ServerName: "talk.google.com",
InsecureSkipVerify: false,
}
talk, err := xmpp.NewClient("talk.google.com:443", username_, password_, false)
if err != nil {
log.Fatal(err)

View File

@ -2,6 +2,7 @@ package main
import (
"bufio"
"crypto/tls"
"flag"
"fmt"
"github.com/mattn/go-xmpp"
@ -17,6 +18,10 @@ var notls = flag.Bool("notls", false, "No TLS")
var debug = flag.Bool("debug", false, "debug output")
var session = flag.Bool("session", false, "use server session")
func serverName(host string) string {
return strings.Split(host, ":")[0]
}
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "usage: example [options]\n")
@ -28,6 +33,13 @@ func main() {
flag.Usage()
}
if !*notls {
xmpp.DefaultConfig = tls.Config {
ServerName: serverName(*server),
InsecureSkipVerify: false,
}
}
var talk *xmpp.Client
var err error
options := xmpp.Options{Host: *server,