# HG changeset patch # User Chris Jones # Date 1325103286 25200 # Node ID d6b7b4cbf50d0b9009c2ce3e81678094c2e333ca # Parent 8f6ae5cfc9b9e7ea9a5e4efcbf900fbfa4d2e89a Made the stream type non-public. diff -r 8f6ae5cfc9b9 -r d6b7b4cbf50d stream.go --- a/stream.go Wed Dec 28 13:05:59 2011 -0700 +++ b/stream.go Wed Dec 28 13:14:46 2011 -0700 @@ -202,7 +202,7 @@ case x := <- srvIn: send := false switch obj := x.(type) { - case *Stream: + case *stream: handleStream(obj) case *Features: cl.handleFeatures(obj) @@ -237,7 +237,7 @@ } } -func handleStream(ss *Stream) { +func handleStream(ss *stream) { } func (cl *Client) handleFeatures(fe *Features) { @@ -288,7 +288,7 @@ // Now re-send the initial handshake message to start the new // session. - hsOut := &Stream{To: cl.Jid.Domain, Version: Version} + hsOut := &stream{To: cl.Jid.Domain, Version: Version} cl.xmlOut <- hsOut } @@ -345,7 +345,7 @@ log.Println("SASL authentication failed") case "success": log.Println("SASL authentication succeeded") - ss := &Stream{To: cl.Jid.Domain, Version: Version} + ss := &stream{To: cl.Jid.Domain, Version: Version} cl.xmlOut <- ss } } diff -r 8f6ae5cfc9b9 -r d6b7b4cbf50d structs.go --- a/structs.go Wed Dec 28 13:05:59 2011 -0700 +++ b/structs.go Wed Dec 28 13:14:46 2011 -0700 @@ -30,16 +30,15 @@ var _ flag.Value = &JID{} // XMPP's XML element -// BUG(cjyar) Hide this. -type Stream struct { +type stream struct { To string `xml:"attr"` From string `xml:"attr"` Id string `xml:"attr"` Lang string `xml:"attr"` Version string `xml:"attr"` } -var _ xml.Marshaler = &Stream{} -var _ fmt.Stringer = &Stream{} +var _ xml.Marshaler = &stream{} +var _ fmt.Stringer = &stream{} // // BUG(cjyar) Can this be consolidated with Error? Hide it if not. @@ -49,7 +48,7 @@ } var _ xml.Marshaler = &StreamError{} -// BUG(cjyar) Replace this with Unrecognized. +// BUG(cjyar) Replace this with Generic. type definedCondition struct { // Must always be in namespace nsStreams XMLName xml.Name @@ -189,7 +188,7 @@ return true } -func (s *Stream) MarshalXML() ([]byte, os.Error) { +func (s *stream) MarshalXML() ([]byte, os.Error) { buf := bytes.NewBuffer(nil) buf.WriteString("` assertMarshal(t, exp, s) - s = &Stream{To: "bob", From: "alice", Id: "#3", Version: "5.3"} + s = &stream{To: "bob", From: "alice", Id: "#3", Version: "5.3"} exp = `` assertMarshal(t, exp, s) - s = &Stream{Lang: "en_US"} + s = &stream{Lang: "en_US"} exp = `` assertMarshal(t, exp, s) diff -r 8f6ae5cfc9b9 -r d6b7b4cbf50d xmpp.go --- a/xmpp.go Wed Dec 28 13:05:59 2011 -0700 +++ b/xmpp.go Wed Dec 28 13:14:46 2011 -0700 @@ -123,7 +123,7 @@ clOut := startStreamWriter(cl.xmlOut) // Initial handshake. - hsOut := &Stream{To: jid.Domain, Version: Version} + hsOut := &stream{To: jid.Domain, Version: Version} cl.xmlOut <- hsOut cl.In = clIn diff -r 8f6ae5cfc9b9 -r d6b7b4cbf50d xmpp_test.go --- a/xmpp_test.go Wed Dec 28 13:05:59 2011 -0700 +++ b/xmpp_test.go Wed Dec 28 13:14:46 2011 -0700 @@ -52,9 +52,9 @@ ch := make(chan interface{}) go readXml(r, ch) x := <- ch - ss, ok := x.(*Stream) + ss, ok := x.(*stream) if !ok { - t.Fatalf("not Stream: %v", reflect.TypeOf(x)) + t.Fatalf("not stream: %v", reflect.TypeOf(x)) } assertEquals(t, "foo.com", ss.To) assertEquals(t, "bar.org", ss.From) @@ -95,7 +95,7 @@ } func TestWriteStream(t *testing.T) { - ss := &Stream{To: "foo.org", From: "bar.com", Id: "42", Lang: + ss := &stream{To: "foo.org", From: "bar.com", Id: "42", Lang: "en", Version: "1.0"} str := testWrite(ss) exp := `