xmpp/xmpp.go
changeset 134 80b764fa2f08
parent 132 feaa24de9597
child 135 a4755a42af19
equal deleted inserted replaced
133:c4e0b897db83 134:80b764fa2f08
   141 	cl.Jid = *jid
   141 	cl.Jid = *jid
   142 	cl.socket = tcp
   142 	cl.socket = tcp
   143 	cl.handlers = make(chan *stanzaHandler, 100)
   143 	cl.handlers = make(chan *stanzaHandler, 100)
   144 	cl.inputControl = make(chan int)
   144 	cl.inputControl = make(chan int)
   145 	cl.tlsConfig = tlsconf
   145 	cl.tlsConfig = tlsconf
       
   146 	cl.sendFilterAdd = make(chan Filter)
       
   147 	cl.recvFilterAdd = make(chan Filter)
   146 
   148 
   147 	extStanza := make(map[xml.Name]reflect.Type)
   149 	extStanza := make(map[xml.Name]reflect.Type)
   148 	for _, ext := range exts {
   150 	for _, ext := range exts {
   149 		for k, v := range ext.StanzaHandlers {
   151 		for k, v := range ext.StanzaHandlers {
   150 			if _, ok := extStanza[k]; ok {
   152 			if _, ok := extStanza[k]; ok {
   180 	recvFiltXmpp := make(chan Stanza)
   182 	recvFiltXmpp := make(chan Stanza)
   181 	cl.Recv = recvFiltXmpp
   183 	cl.Recv = recvFiltXmpp
   182 	go filterMgr(cl.recvFilterAdd, recvRawXmpp, recvFiltXmpp)
   184 	go filterMgr(cl.recvFilterAdd, recvRawXmpp, recvFiltXmpp)
   183 	sendFiltXmpp := make(chan Stanza)
   185 	sendFiltXmpp := make(chan Stanza)
   184 	cl.Send = sendFiltXmpp
   186 	cl.Send = sendFiltXmpp
   185 	go filterMgr(cl.sendFilterAdd, sendFiltXmpp, sendFiltXmpp)
   187 	go filterMgr(cl.sendFilterAdd, sendFiltXmpp, sendRawXmpp)
       
   188 	// Set up the initial filters.
       
   189 	for _, ext := range exts {
       
   190 		cl.AddRecvFilter(ext.RecvFilter)
       
   191 		cl.AddSendFilter(ext.SendFilter)
       
   192 	}
   186 
   193 
   187 	// Initial handshake.
   194 	// Initial handshake.
   188 	hsOut := &stream{To: jid.Domain, Version: XMPPVersion}
   195 	hsOut := &stream{To: jid.Domain, Version: XMPPVersion}
   189 	cl.sendXml <- hsOut
   196 	cl.sendXml <- hsOut
   190 
   197