diff options
Diffstat (limited to 'xmpp/xmpp.go')
-rw-r--r-- | xmpp/xmpp.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/xmpp/xmpp.go b/xmpp/xmpp.go index 624090b..07d4c6d 100644 --- a/xmpp/xmpp.go +++ b/xmpp/xmpp.go @@ -19,6 +19,7 @@ type Conn struct { ch chan Event jid, pwd string tcp *tls.Conn + enc encoder } func NewConn(ch chan Event, jid string, pwd string) *Conn { @@ -65,13 +66,13 @@ func (c *Conn) Run() { go decoder.run() defer decoder.stop() - enc := newEncoder(c.tcp) - defer enc.Close() + c.enc = newEncoder(c.tcp) + defer c.enc.Close() - tr := newTokenRouter(&enc) + tr := newTokenRouter() - end := sendStreamStart(&enc, c.jid) - defer sendStreamEnd(&enc, end) + end := sendStreamStart(&c.enc, c.jid) + defer sendStreamEnd(&c.enc, end) c.ch <- ConnectEvent defer func() { c.ch <- DisconnectEvent }() @@ -86,7 +87,7 @@ func (c *Conn) Run() { log.Printf("Unknown Event '%d'!\n", ev) } case token := <-decoder.data: - err = tr.route(token) + err = tr.route(token, c) if err != nil { log.Println(err) return |