hipchat.go
func NewClientWithServerInfo(user, pass, resource, authType, host, domain, conf string) (*Client, error) {
	connection, err := xmpp.Dial(host)

	var b bytes.Buffer
	if err := xml.EscapeText(&b, []byte(pass)); err != nil {
		return nil, err
	}

	c := &Client{
		AuthType: authType,
		Username: user,
		Password: b.String(),
		Resource: resource,
		Id:       user + "@" + domain,

		// private
		connection:      connection,
		mentionNames:    make(map[string]string),
		receivedUsers:   make(chan []*User),
		receivedRooms:   make(chan []*Room),
		receivedMessage: make(chan *Message),
		host:            host,
		domain:          domain,
		conf:            conf,
	}

	if err != nil {
		return c, err
	}

	err = c.authenticate()
	if err != nil {
		return c, err
	}

	go c.listen()
	return c, nil
}
func NewClientWithServerInfo(user, pass, resource, authType, host, domain, conf string) (*Client, error) {
	connection, err := xmpp.Dial(host)

	var b bytes.Buffer
	if err := xml.EscapeText(&b, []byte(pass)); err != nil {
		return nil, err
	}

	c := &Client{
		AuthType: authType,
		Username: user,
		Password: b.String(),
		Resource: resource,
		Id:       user + "@" + domain,

		// private
		connection:      connection,
		mentionNames:    make(map[string]string),
		receivedUsers:   make(chan []*User),
		receivedRooms:   make(chan []*Room),
		receivedMessage: make(chan *Message),
		host:            host,
		domain:          domain,
		conf:            conf,
	}

	if err != nil {
		return c, err
	}

	err = c.authenticate()
	if err != nil {
		return c, err
	}

	go c.listen()
	return c, nil
}
// NewClientWithServerInfo creates a new Client connection from the user name, password,
// resource, host URL and conf URL passed to it.