當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Element.Text方法代碼示例

本文整理匯總了Golang中github.com/skriptble/nine/element.Element.Text方法的典型用法代碼示例。如果您正苦於以下問題:Golang Element.Text方法的具體用法?Golang Element.Text怎麽用?Golang Element.Text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/skriptble/nine/element.Element的用法示例。


在下文中一共展示了Element.Text方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: HandleElement

func (h *Handler) HandleElement(el element.Element, props stream.Properties) (
	[]element.Element, stream.Properties) {
	var elems []element.Element
	var challenge bool
	switch el.Tag {
	case "auth":
		mechName := el.SelectAttrValue("mechanism", "")
		mech, ok := h.mechs[mechName]
		if !ok {
			elems = append(elems, element.SASLFailure.InvalidMechanism)
			break
		}
		data := el.Text()
		log.Println("Authenticating")
		elems, props, challenge = mech.Authenticate(data, props)
		if challenge {
			h.current = mech
		}
	case "response":
		if h.current == nil {
			el := element.SASLFailure.NotAuthorized.
				AddChild(element.New("text").SetText("Out of order SASL element"))
			elems = append(elems, el)
		}
		data := el.Text()
		elems, props, challenge = h.current.Authenticate(data, props)
		if !challenge {
			h.current = nil
		}
	}
	return elems, props
}
開發者ID:skriptble,項目名稱:nine,代碼行數:32,代碼來源:handler.go

示例2: TransformPresence

func TransformPresence(el element.Element) (Presence, error) {
	if el.Tag != "presence" {
		return Presence{}, ErrNotPresence
	}
	presence := Presence{}
	presence.To = el.SelectAttrValue("to", "")
	presence.From = el.SelectAttrValue("from", "")
	presence.ID = el.SelectAttrValue("id", "")
	presence.Type = el.SelectAttrValue("type", "")
	presence.Lang = el.SelectAttrValue("xml:lang", "")
	presence.Data = el.Text()

	presence.Children = el.ChildElements()
	presence.Tag, presence.Space = el.Tag, el.Space

	return presence, nil
}
開發者ID:skriptble,項目名稱:nine,代碼行數:17,代碼來源:stanza.go

示例3: TransformMessage

func TransformMessage(el element.Element) (Message, error) {
	if el.Tag != "message" {
		return Message{}, ErrNotMessage
	}
	message := Message{}
	message.To = el.SelectAttrValue("to", "")
	message.From = el.SelectAttrValue("from", "")
	message.ID = el.SelectAttrValue("id", "")
	message.Type = el.SelectAttrValue("type", "")
	message.Lang = el.SelectAttrValue("xml:lang", "")
	message.Data = el.Text()

	message.Children = el.ChildElements()
	message.Tag, message.Space = el.Tag, el.Space

	return message, nil
}
開發者ID:skriptble,項目名稱:nine,代碼行數:17,代碼來源:stanza.go

示例4: TransformIQ

func TransformIQ(el element.Element) IQ {
	if el.Tag != "iq" {
		return IQEmpty
	}
	iq := IQ{}
	iq.To = el.SelectAttrValue("to", "")
	iq.From = el.SelectAttrValue("from", "")
	iq.ID = el.SelectAttrValue("id", "")
	iq.Type = el.SelectAttrValue("type", "")
	iq.Lang = el.SelectAttrValue("xml:lang", "")
	iq.Data = el.Text()

	iq.Children = el.ChildElements()
	iq.Tag, iq.Space = el.Tag, el.Space

	return iq
}
開發者ID:skriptble,項目名稱:nine,代碼行數:17,代碼來源:iq.go


注:本文中的github.com/skriptble/nine/element.Element.Text方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。