本文整理汇总了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
}
示例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
}
示例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
}
示例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
}