blob: 14113a6726ea22277313e26e9652762a8524659f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package xmpp
import (
"encoding/xml"
"log"
"os"
)
type encoderDecoder struct{
session *session
ct *xml.Encoder // client transport encoder
cl *xml.Encoder // client log encoder
}
func newEncoderDecoder(s *session) encoderDecoder {
ed := encoderDecoder{}
ed.session = s
ed.ct = xml.NewEncoder(s.transport)
ed.ct.Indent("", " ")
ed.cl = xml.NewEncoder(os.Stdout)
ed.cl.Indent("C: ", " ")
return ed
}
func (ed *encoderDecoder) encodeToken(t xml.Token) error {
var err error
defer func() { if err != nil { log.Println(err) } }()
err = ed.ct.EncodeToken(t)
if err != nil { return err }
err = ed.ct.Flush()
if err != nil { return err }
err = ed.cl.EncodeToken(t)
if err != nil { return err }
err = ed.cl.Flush()
if err != nil { return err }
return nil
}
|