func connectXMPP(c xmppC, isSandbox bool, senderID string, apiKey string,
	h MessageHandler, cerr chan<- error, debug bool, omitRetry bool) (xmppC, error) {
	var xmppc xmppC
	if c != nil {
		// Use the provided client.
		xmppc = c
	} else {
		// Create new.
		var err error
		xmppc, err = newXMPPClient(isSandbox, senderID, apiKey, debug, omitRetry)
		if err != nil {
			cerr <- err
			return nil, err
		}
	}

	l := log.WithField("xmpp client ref", xmppc.ID())

	// Start listening on this connection.
	go func() {
		l.Debug("gcm xmpp listen started")
		if err := xmppc.Listen(h); err != nil {
			l.WithField("error", err).Error("gcm xmpp listen")
			cerr <- err
		}
		l.Debug("gcm xmpp listen finished")
	}()

	return xmppc, nil
}
// Creates a new xmpp client (if not provided), connects to the server and starts listening.
Creates a new xmpp client (if not provided), connects to the server and starts listening.
// Creates a new xmpp client ( if not provided ) connects to the server and starts listening .
func connectXMPP(c xmppC, isSandbox bool, senderID string, apiKey string,
	h MessageHandler, cerr chan<- error, debug bool, omitRetry bool) (xmppC, error) {
	var xmppc xmppC
	if c != nil {
		xmppc = c
	} else {
		var err error
		xmppc, err = newXMPPClient(isSandbox, senderID, apiKey, debug, omitRetry)
		if err != nil {
			cerr <- err
			return nil, err
		}
	}
	l := log.WithField("xmpp client ref", xmppc.ID())
	go func() {
		l.Debug("gcm xmpp listen started")
		if err := xmppc.Listen(h); err != nil {
			l.WithField("error", err).Error("gcm xmpp listen")
			cerr <- err
		}
		l.Debug("gcm xmpp listen finished")
	}()
	return xmppc, nil
}
func connectXMPP ( c xmppC , isSandbox bool , senderID string , apiKey string , h MessageHandler , cerr chan <- error , debug bool , omitRetry bool ) ( xmppC , error ) { var xmppc xmppC if c != nil { xmppc = c } else { var err error xmppc , err = newXMPPClient ( isSandbox , senderID , apiKey , debug , omitRetry ) if err != nil { cerr <- err return nil , err } } l := log . WithField ( " " , xmppc . ID ( ) ) go func ( ) { l . Debug ( " " ) if err := xmppc . Listen ( h ) ; err != nil { l . WithField ( " " , err ) . Error ( " " ) cerr <- err } l . Debug ( " " ) } ( ) return xmppc , nil }
Creates a new xmpp client (if not provided), connects to the server and starts listening.
Creates a new xmpp client ( if not provided ) connects to the server and starts listening .
// Use the provided client. // Create new. // Start listening on this connection.