2
0
mirror of https://github.com/FluuxIO/go-xmpp synced 2024-11-15 18:13:07 +00:00
go-xmpp/message.go
2018-01-01 18:12:33 +01:00

25 lines
602 B
Go

package xmpp // import "fluux.io/xmpp"
import (
"encoding/xml"
"fmt"
)
// XMPP Packet Parsing
type ClientMessage struct {
XMLName xml.Name `xml:"jabber:client message"`
Packet
Subject string `xml:"subject,omitempty"`
Body string `xml:"body,omitempty"`
Thread string `xml:"thread,omitempty"`
}
// TODO: Func new message to create an empty message structure without the XML tag matching elements
func (message *ClientMessage) XMPPFormat() string {
return fmt.Sprintf("<message to='%s' type='chat' xml:lang='en'>"+
"<body>%s</body></message>",
message.To,
xmlEscape(message.Body))
}