xmpp

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 9 Imported by: 2

README

go-xmpp

Documentation

src.agwa.name/go-xmpp is a Go library that I use with my XMPP projects. It is not intended for general use.

Credits

go-xmpp builds on the work of Sheena Artrip and Michael Hendricks.

Documentation

Index

Constants

View Source
const (

	// CHAT defines the chat message type
	CHAT = MessageType("chat")

	// ERROR defines the error message type
	ERROR = MessageType("error")

	// GROUPCHAT defines the group chat message type
	GROUPCHAT = MessageType("groupchat")

	// HEADLINE defines the headline message type
	HEADLINE = MessageType("headline")

	// NORMAL defines the normal message type
	NORMAL = MessageType("normal")
)
View Source
const (

	// SUBSCRIBE represents the subscribe Presence message type
	SUBSCRIBE = "subscribe"

	// SUBSCRIBED represents the subscribed Presence message type
	SUBSCRIBED = "subscribed"

	// UNSUBSCRIBE represents the unsubsribe Presence message type
	UNSUBSCRIBE = "unsubscribe"

	// UNSUBSCRIBED represents the unsubsribed Presence message type
	UNSUBSCRIBED = "unsubscribed"

	// UNAVAILABLE represents the unavailable Presence message type
	UNAVAILABLE = "unavailable"

	// PROBE represents the probe Presence message type
	PROBE = "probe"
)

Variables

This section is empty.

Functions

func NewReadLogger

func NewReadLogger(log *log.Logger, r io.Reader) io.Reader

NewReadLogger returns a reader that behaves like r except that it logs the string read.

func NewWriteLogger

func NewWriteLogger(log *log.Logger, w io.Writer) io.Writer

NewWriteLogger returns a writer that behaves like w except that it logs the string written.

func RandomID

func RandomID() string

Types

type Address

type Address struct {
	LocalPart    string
	DomainPart   string
	ResourcePart string
}

Address is an XMPP JID address

func ParseAddress

func ParseAddress(s string) (Address, error)

ParseAddress parses the address from the given string

func (*Address) Bare

func (a *Address) Bare() *Address

Bare returns a copy of this address with the resource part made blank.

func (*Address) Equals

func (a *Address) Equals(o *Address) bool

Equals compares the given address

func (*Address) MarshalXMLAttr

func (a *Address) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr marks the Address struct as being able to be written as an XML attribute

func (*Address) String

func (a *Address) String() string

String formats the address as an XMPP JID

func (*Address) UnmarshalXMLAttr

func (a *Address) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr marks the Address struct as being able to be parsed as an XML attribute

type DiscoFeature

type DiscoFeature struct {
	// Var is a mandatory protocol namespace offered by the entity.
	Var string `xml:"var,attr"`

	XMLName string `xml:"feature"`
}

DiscoFeature represents a feature element in a response to a service discovery info query.

See the registry of features at http://xmpp.org/registrar/disco-features.html

type DiscoIdentity

type DiscoIdentity struct {
	// Category is a mandatory description of the category of this
	// identity.  Category often contains values like "conference",
	// "directory", "gateway", "server", "client", etc.
	//
	// See the category registry at http://xmpp.org/registrar/disco-categories.html
	Category string `xml:"category,attr"`

	// Type is a mandatory description of the type of this identity.
	// The type goes together with the Category to help requesting
	// entities know which services are offered.
	//
	// For example, if Category is "gateway" then Type might be "msn"
	// or "aim".  See the type registry at http://xmpp.org/registrar/disco-categories.html
	Type string `xml:"type,attr"`

	// Name is an optional natural language name for the entity
	// described by this identity.
	Name string `xml:"name,attr,omitempty"`

	XMLName string `xml:"identity"`
}

DiscoIdentity represents an identity element in a response to a service discovery info query.

type DiscoInfoQuery

type DiscoInfoQuery struct {
	Identities []DiscoIdentity
	Features   []DiscoFeature

	XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"`
}

DiscoInfoQuery represents a service discovery info query message. See section 3.1 in XEP-0030.

type Error

type Error struct {
	XMLName xml.Name

	Code string `xml:"code,omitempty,attr"`
	Type string `xml:"type,omitempty,attr"`
}

Error is the error sent over XMPP

func (*Error) String

func (e *Error) String() string
type Header struct {
	ID   string   `xml:"id,attr,omitempty"`
	From *Address `xml:"from,attr,omitempty"`
	To   *Address `xml:"to,attr,omitempty"`
}

Header contains the common fields for every XEP-0114 message

type Iq

type Iq struct {
	Header

	Type        string       `xml:"type,attr"`
	Vcard       *Vcard       `xml:"vcard-temp vCard,omitempty"`
	RosterQuery *RosterQuery `xml:"jabber:iq:roster query,omitempty"`
	Content     []byte       `xml:",innerxml"`
	XMLName     string       `xml:"iq"`
}

Iq represents an info/query message

func (*Iq) IsDiscoInfo

func (iq *Iq) IsDiscoInfo() bool

IsDiscoInfo returns true if an iq stanza is a service discovery info query.

type Message

type Message struct {
	Header
	Type MessageType `xml:"type,attr,omitempty"`

	Subject string `xml:"subject,omitempty"`
	Body    string `xml:"body,omitempty"`
	Error   *Error `xml:"error"`
	Thread  string `xml:"thread,omitempty"`
	Content string `xml:",innerxml"` // allow arbitrary content

	// XEP-0184 message delivery receipts
	ReceiptRequest *xml.Name   `xml:"urn:xmpp:receipts request,omitempty"`
	ReceiptAck     *ReceiptAck `xml:"urn:xmpp:receipts received,omitempty"`

	// XEP-0172 User nicknames
	Nick string `xml:"http://jabber.org/protocol/nick nick,omitempty"`

	// XEP-0066 Out of Band Data
	OutOfBandData *OutOfBandData `xml:"jabber:x:oob x,omitempty"`

	XMLName xml.Name `xml:"message"`
}

A Message is an incoming or outgoing XMPP message

func (*Message) Response

func (m *Message) Response() *Message

Response returns a new message representing a response to this message. The To and From attributes of the header are reversed to indicate the new origin.

type MessageType

type MessageType string

MessageType defines the constants for the types of messages within XEP-0114

type OutOfBandData

type OutOfBandData struct {
	URL  string `xml:"url"`
	Desc string `xml:"desc,omitempty"`
}

XEP-0066, Out of Band Data

type Presence

type Presence struct {
	Header

	Show     string `xml:"show,omitempty"`
	Status   string `xml:"status,omitempty"`
	Priority byte   `xml:"priority,omitempty"`

	Type string `xml:"type,attr,omitempty"`

	// XEP-0172 User nicknames
	Nick string `xml:"http://jabber.org/protocol/nick nick,omitempty"`

	XMLName string `xml:"presence"`
}

Presence represents a message identifying whether an entity is available and the subscription requests/responses for the entity

type ReceiptAck

type ReceiptAck struct {
	ID string `xml:"id,attr"`
}

ReceiptAck represents an acknowledgement that the message with ID has been received.

type RosterItem

type RosterItem struct {
	XMLName xml.Name `xml:"item"`

	JID          Address  `xml:"jid,attr"`
	Name         string   `xml:"name,attr,omitempty"`
	Subscription string   `xml:"subscription,attr"`
	Groups       []string `xml:"group"`
}

type RosterQuery

type RosterQuery struct {
	XMLName xml.Name `xml:"jabber:iq:roster query"`

	Items []RosterItem `xml:"item"`
}

type Vcard

type Vcard struct {
	FullName string `xml:"FN,omitempty"`
}

Vcard represents details about a XEP-0054 vCard.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL