xmpp.go
changeset 12 122ab6208c3c
parent 11 48be1ae93fd4
child 13 c9527bbe99a6
equal deleted inserted replaced
11:48be1ae93fd4 12:122ab6208c3c
    22 	// Various XML namespaces.
    22 	// Various XML namespaces.
    23 	nsStreams = "urn:ietf:params:xml:ns:xmpp-streams"
    23 	nsStreams = "urn:ietf:params:xml:ns:xmpp-streams"
    24 	nsStream = "http://etherx.jabber.org/streams"
    24 	nsStream = "http://etherx.jabber.org/streams"
    25 	nsTLS = "urn:ietf:params:xml:ns:xmpp-tls"
    25 	nsTLS = "urn:ietf:params:xml:ns:xmpp-tls"
    26 	nsSASL = "urn:ietf:params:xml:ns:xmpp-sasl"
    26 	nsSASL = "urn:ietf:params:xml:ns:xmpp-sasl"
       
    27 	nsBind = "urn:ietf:params:xml:ns:xmpp-bind"
    27 
    28 
    28 	// DNS SRV names
    29 	// DNS SRV names
    29 	serverSrv = "xmpp-server"
    30 	serverSrv = "xmpp-server"
    30 	clientSrv = "xmpp-client"
    31 	clientSrv = "xmpp-client"
    31 
    32 
    37 	Jid JID
    38 	Jid JID
    38 	password string
    39 	password string
    39 	socket net.Conn
    40 	socket net.Conn
    40 	socketSync sync.WaitGroup
    41 	socketSync sync.WaitGroup
    41 	saslExpected string
    42 	saslExpected string
       
    43 	authDone bool
       
    44 	idMutex sync.Mutex
       
    45 	nextId int64
    42 	In <-chan interface{}
    46 	In <-chan interface{}
    43 	Out chan<- interface{}
    47 	Out chan<- interface{}
    44 	xmlOut chan<- interface{}
    48 	xmlOut chan<- interface{}
    45 	TextOut chan<- *string
    49 	TextOut chan<- *string
    46 }
    50 }
   198 		} else if ch, ok := x.(<-chan interface{}) ; ok {
   202 		} else if ch, ok := x.(<-chan interface{}) ; ok {
   199 			f2(ch)
   203 			f2(ch)
   200 		}
   204 		}
   201 	}
   205 	}
   202 }
   206 }
       
   207 
       
   208 func (cl *Client) NextId() string {
       
   209 	cl.idMutex.Lock()
       
   210 	defer cl.idMutex.Unlock()
       
   211 	id := cl.nextId
       
   212 	cl.nextId++
       
   213 	return fmt.Sprintf("id_%d", id)
       
   214 }