~samwhited/xmpp

4063f61dda670a932e2690a8764b0f73e8833d55 — Sam Whited 4 years ago c7dbd84
all: update xmlstream
4 files changed, 8 insertions(+), 20 deletions(-)

M Gopkg.toml
M session.go
M stanza/example_pingstream_test.go
M stanza/stanza_test.go
M Gopkg.toml => Gopkg.toml +1 -1
@@ 33,5 33,5 @@
  name = "mellium.im/sasl"

[[constraint]]
	version = "0.8"
	version = "0.9"
  name = "mellium.im/xmlstream"

M session.go => session.go +1 -1
@@ 317,7 317,7 @@ func (s *Session) handleInputStream(handler Handler) error {
				}
			}
			// Advance the stream to the end of the element.
			if err = xmlstream.Copy(xmlstream.Discard(), ir); err != nil {
			if _, err = xmlstream.Copy(xmlstream.Discard(), ir); err != nil {
				return err
			}
		case xml.EndElement:

M stanza/example_pingstream_test.go => stanza/example_pingstream_test.go +3 -15
@@ 6,7 6,6 @@ package stanza_test

import (
	"encoding/xml"
	"io"
	"log"
	"os"



@@ 18,19 17,8 @@ import (
// WrapPingIQ returns an xmlstream.TokenReader that outputs a new IQ stanza with
// a ping payload.
func WrapPingIQ(to *jid.JID) xmlstream.TokenReader {
	state := 0
	start := xml.StartElement{Name: xml.Name{Local: "ping", Space: `urn:xmpp:ping`}}
	return stanza.WrapIQ(to, stanza.GetIQ, xmlstream.ReaderFunc(func() (xml.Token, error) {
		switch state {
		case 0:
			state++
			return start, nil
		case 1:
			state++
			return start.End(), io.EOF
		}
		return nil, io.EOF
	}))
	start := xml.StartElement{Name: xml.Name{Local: "ping", Space: "urn:xmpp:ping"}}
	return stanza.WrapIQ(to, stanza.GetIQ, xmlstream.Wrap(nil, start))
}

func Example_stream() {


@@ 39,7 27,7 @@ func Example_stream() {
	e.Indent("", "\t")

	ping := WrapPingIQ(j)
	if err := xmlstream.Copy(e, ping); err != nil {
	if _, err := xmlstream.Copy(e, ping); err != nil {
		log.Fatal(err)
	}
	// Output:

M stanza/stanza_test.go => stanza/stanza_test.go +3 -3
@@ 59,7 59,7 @@ func TestIQ(t *testing.T) {
			b := new(bytes.Buffer)
			e := xml.NewEncoder(b)
			iq := stanza.WrapIQ(jid.MustParse(tc.to), tc.typ, tc.payload)
			if err := xmlstream.Copy(e, iq); err != tc.err {
			if _, err := xmlstream.Copy(e, iq); err != tc.err {
				t.Errorf("Unexpected error: want=`%v', got=`%v'", tc.err, err)
			}



@@ 106,7 106,7 @@ func TestMessage(t *testing.T) {
			b := new(bytes.Buffer)
			e := xml.NewEncoder(b)
			message := stanza.WrapMessage(jid.MustParse(tc.to), tc.typ, tc.payload)
			if err := xmlstream.Copy(e, message); err != tc.err {
			if _, err := xmlstream.Copy(e, message); err != tc.err {
				t.Errorf("Unexpected error: want=`%v', got=`%v'", tc.err, err)
			}



@@ 153,7 153,7 @@ func TestPresence(t *testing.T) {
			b := new(bytes.Buffer)
			e := xml.NewEncoder(b)
			presence := stanza.WrapPresence(jid.MustParse(tc.to), tc.typ, tc.payload)
			if err := xmlstream.Copy(e, presence); err != tc.err {
			if _, err := xmlstream.Copy(e, presence); err != tc.err {
				t.Errorf("Unexpected error: want=`%v', got=`%v'", tc.err, err)
			}