xmpp/layer2.go
changeset 147 d7679d991b17
parent 145 21a390dd3506
child 163 3f891f7fe817
equal deleted inserted replaced
146:aa9a0ae8f875 147:d7679d991b17
     9 	"io"
     9 	"io"
    10 	"reflect"
    10 	"reflect"
    11 	"strings"
    11 	"strings"
    12 )
    12 )
    13 
    13 
    14 func readXml(r io.Reader, ch chan<- interface{},
    14 // Read bytes from a reader, unmarshal them as XML into structures of
       
    15 // the appropriate type, and send those structures on a channel.
       
    16 func recvXml(r io.Reader, ch chan<- interface{},
    15 	extStanza map[xml.Name]reflect.Type) {
    17 	extStanza map[xml.Name]reflect.Type) {
    16 	if _, ok := Debug.(*noLog); !ok {
    18 	if _, ok := Debug.(*noLog); !ok {
    17 		pr, pw := io.Pipe()
    19 		pr, pw := io.Pipe()
    18 		go tee(r, pw, "S: ")
    20 		go tee(r, pw, "S: ")
    19 		r = pr
    21 		r = pr
   127 	}
   129 	}
   128 
   130 
   129 	return nil
   131 	return nil
   130 }
   132 }
   131 
   133 
   132 func writeXml(w io.Writer, ch <-chan interface{}) {
   134 // Receive structures on a channel, marshal them to XML, and send the
       
   135 // bytes on a writer.
       
   136 func sendXml(w io.Writer, ch <-chan interface{}) {
   133 	if _, ok := Debug.(*noLog); !ok {
   137 	if _, ok := Debug.(*noLog); !ok {
   134 		pr, pw := io.Pipe()
   138 		pr, pw := io.Pipe()
   135 		go tee(pr, w, "C: ")
   139 		go tee(pr, w, "C: ")
   136 		w = pw
   140 		w = pw
   137 	}
   141 	}