# HG changeset patch # User Chris Jones # Date 1379269897 21600 # Node ID 9d7fdb1d2fc1d3c6f7467ca050f1c5e11806752b # Parent 62166e57800ee79dc6c583fee048e8636d354e29 Renamed HandleStanza to SetCallback. diff -r 62166e57800e -r 9d7fdb1d2fc1 TODO.txt --- a/TODO.txt Sun Sep 15 12:00:17 2013 -0600 +++ b/TODO.txt Sun Sep 15 12:31:37 2013 -0600 @@ -4,9 +4,6 @@ Maybe put auth-related stuff into its own structure inside Client, instead of at Client's top level. -Rename stanzaHandler to something like idCallback. Same for the -HandleStanza function. - Replace inputControl with something like an enum. Add a way to broadcast status information as negotiation happens or diff -r 62166e57800e -r 9d7fdb1d2fc1 xmpp/layer3.go --- a/xmpp/layer3.go Sun Sep 15 12:00:17 2013 -0600 +++ b/xmpp/layer3.go Sun Sep 15 12:31:37 2013 -0600 @@ -10,7 +10,7 @@ ) // Callback to handle a stanza with a particular id. -type stanzaHandler struct { +type callback struct { id string // Return true means pass this to the application f func(Stanza) bool @@ -168,11 +168,11 @@ // Register a callback to handle the next XMPP stanza (iq, message, or // presence) with a given id. The provided function will not be called // more than once. If it returns false, the stanza will not be made -// available on the normal Client.In channel. The stanza handler -// must not read from that channel, as deliveries on it cannot proceed -// until the handler returns true or false. -func (cl *Client) HandleStanza(id string, f func(Stanza) bool) { - h := &stanzaHandler{id: id, f: f} +// available on the normal Client.Recv channel. The callback must not +// read from that channel, as deliveries on it cannot proceed until +// the handler returns true or false. +func (cl *Client) SetCallback(id string, f func(Stanza) bool) { + h := &callback{id: id, f: f} cl.handlers <- h } @@ -220,6 +220,6 @@ cl.bindDone() return false } - cl.HandleStanza(msg.Id, f) + cl.SetCallback(msg.Id, f) cl.sendXml <- msg } diff -r 62166e57800e -r 9d7fdb1d2fc1 xmpp/xmpp.go --- a/xmpp/xmpp.go Sun Sep 15 12:00:17 2013 -0600 +++ b/xmpp/xmpp.go Sun Sep 15 12:31:37 2013 -0600 @@ -67,7 +67,7 @@ socketSync sync.WaitGroup saslExpected string authDone bool - handlers chan *stanzaHandler + handlers chan *callback inputControl chan int // Incoming XMPP stanzas from the remote will be published on // this channel. Information which is used by this library to @@ -137,7 +137,7 @@ cl.password = password cl.Jid = *jid cl.socket = tcp - cl.handlers = make(chan *stanzaHandler, 100) + cl.handlers = make(chan *callback, 100) cl.inputControl = make(chan int) cl.tlsConfig = tlsconf cl.sendFilterAdd = make(chan Filter) @@ -257,7 +257,7 @@ ch <- nil return false } - cl.HandleStanza(id, f) + cl.SetCallback(id, f) cl.Send <- iq // Now wait until the callback is called.