xmppclient

package module
v0.0.0-...-6c44c4c Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2014 License: MIT Imports: 13 Imported by: 3

README

xmppclient

A XMPP Client in Go.

Documentation

Index

Constants

View Source
const (
	AffiliationNone    int = 1
	AffiliationOutcast int = 2
	AffiliationMember  int = 3
	AffiliationOwner   int = 4
	AffiliationAdmin   int = 5
	AffiliationInvalid int = 6
	RoleNone           int = 1
	RoleVisitor        int = 2
	RoleParticipant    int = 3
	RoleModerator      int = 4
	RoleInvalid        int = 5
)

Variables

This section is empty.

Functions

func GetLocalFromJID

func GetLocalFromJID(jid string) string

func IsBareJid

func IsBareJid(jid string) bool

func RemoveResourceFromJid

func RemoveResourceFromJid(jid string) string

RemoveResourceFromJid returns the user@domain portion of a JID.

func SeparateJidAndResource

func SeparateJidAndResource(fullJid string) (bareJid, resource string)

Types

type Active

type Active struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates active"`
}

type BasicHandler

type BasicHandler struct{}

func (*BasicHandler) RecvMsg

func (b *BasicHandler) RecvMsg(msg *ClientMessage)

func (*BasicHandler) RecvPresence

func (b *BasicHandler) RecvPresence(pres *ClientPresence)

type ClientError

type ClientError struct {
	XMLName xml.Name `xml:"jabber:client error"`
	Code    string   `xml:"code,attr"`
	Type    string   `xml:"type,attr"`
	Any     xml.Name `xml:",any"`
	Text    string   `xml:"text"`
}

type ClientIQ

type ClientIQ struct {
	XMLName xml.Name    `xml:"jabber:client iq"`
	From    string      `xml:"from,attr"`
	Id      string      `xml:"id,attr"`
	To      string      `xml:"to,attr"`
	Type    string      `xml:"type,attr"` // error, get, result, set
	Error   ClientError `xml:"error"`
	Bind    bindBind    `xml:"bind"`
	Query   []byte      `xml:",innerxml"`
}

type ClientMessage

type ClientMessage struct {
	XMLName xml.Name `xml:"jabber:client message"`
	From    string   `xml:"from,attr"`
	Id      string   `xml:"id,attr"`
	To      string   `xml:"to,attr"`
	Type    string   `xml:"type,attr"` // chat, error, groupchat, headline, or normal

	// These should technically be []clientText,
	// but string is much more convenient.
	Subject string `xml:"subject"`
	Body    string `xml:"body"`
	Thread  string `xml:"thread"`

	Active      *Active
	Composing   *Composing
	Paused      *Paused
	ConferenceX *ConferenceX `xml:"x"`
}

RFC 3921 B.1 jabber:client

func (*ClientMessage) IsComposing

func (this *ClientMessage) IsComposing() bool

type ClientPresence

type ClientPresence struct {
	XMLName xml.Name `xml:"jabber:client presence"`
	From    string   `xml:"from,attr"`
	Id      string   `xml:"id,attr"`
	To      string   `xml:"to,attr"`
	Type    string   `xml:"type,attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
	Lang    string   `xml:"lang,attr"`

	Show     string `xml:"show"`   // away, chat, dnd, xa
	Status   string `xml:"status"` // sb []clientText
	Priority string `xml:"priority"`
	C        PresenceC
	X        PresenceX    `xml:"x"`
	Error    *ClientError `xml:"error"`
}

func (*ClientPresence) HasNode

func (this *ClientPresence) HasNode() bool

func (*ClientPresence) IsMUC

func (this *ClientPresence) IsMUC() bool

func (*ClientPresence) IsOnline

func (this *ClientPresence) IsOnline() bool

func (*ClientPresence) IsUnavailable

func (this *ClientPresence) IsUnavailable() bool

type ClientText

type ClientText struct {
	Lang string `xml:"lang,attr"`
	Body string `xml:",chardata"`
}

type Composing

type Composing struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates composing"`
}

type ConferenceX

type ConferenceX struct {
	XMLName xml.Name `xml:"jabber:x:conference x`
	Jid     string   `xml:"jid,attr"`
	Reason  string   `xml:"reason,attr"`
}

type Config

type Config struct {
	// InLog is an optional Writer which receives the raw contents of the
	// XML from the server.
	InLog io.Writer
	// OutLog is an option Writer which receives the raw XML sent to the
	// server.
	OutLog io.Writer
	// Log is an optional Writer which receives human readable log messages
	// during the connection.
	Log io.Writer

	TLSRequired bool
}

Config contains options for an XMPP connection.

type Conn

type Conn struct {
	Jid    string
	Domain string

	OnlineRoster []string
	Handler      Handler
	RosterIQMap  map[string]chan *ClientIQ
	// contains filtered or unexported fields
}

Conn represents a connection to an XMPP server.

func Dial

func Dial(address, user, domain, password, resource string, config *Config) (c *Conn, err error)

Dial creates a new connection to an XMPP server and authenticates as the given user.

func (*Conn) Close

func (c *Conn) Close() (err error)

func (*Conn) CreateRoom

func (c *Conn) CreateRoom(jid string)

func (*Conn) DestroyRoom

func (c *Conn) DestroyRoom(jid string) error

func (*Conn) DiscoverRooms

func (c *Conn) DiscoverRooms()

<iq from='hag66@shakespeare.lit/pda'

  id='zb8q41f4'
  to='chat.shakespeare.lit'
  type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>

</iq>

func (*Conn) JoinMUC

func (c *Conn) JoinMUC(jid string, nickname string) error

<presence from='hag66@shakespeare.lit/pda'

to='hoho@conference.shakespeare.lit/nickname'>
<x xmlns='http://jabber.org/protocol/muc'/>

</presence>

func (*Conn) Listen

func (c *Conn) Listen()

func (*Conn) Next

func (c *Conn) Next(ch chan<- Stanza)

Next reads stanzas from the server. If the stanza is a reply, it dispatches it to the correct channel and reads the next message. Otherwise it returns the stanza for processing.

func (*Conn) PresenceMuc

func (c *Conn) PresenceMuc(to string, isJoined bool) (err error)

func (*Conn) RetrieveRoster

func (c *Conn) RetrieveRoster() (err error)

rfc6121 http://www.rfc-editor.org/rfc/rfc6121.txt <iq from='juliet@example.com/balcony'

id='bv1bs71f'
type='get'>
  <query xmlns='jabber:iq:roster'/>

</iq>

func (*Conn) Send

func (c *Conn) Send(to, msg string) error

Send an IM message to the given user.

func (*Conn) SendActive

func (c *Conn) SendActive(to string) error

Send sends an IM message to the given user.

func (*Conn) SendComposing

func (c *Conn) SendComposing(to string) error

Send sends an IM message to the given user.

func (*Conn) SendDirectMucInvitation

func (c *Conn) SendDirectMucInvitation(to string, roomJid string, reason string) error

<message

from='crone1@shakespeare.lit/desktop'
to='hecate@shakespeare.lit'>
  <x xmlns='jabber:x:conference'
    jid='darkcave@macbeth.shakespeare.lit'
    reason='Hey Hecate, this is the place for all good witches!'/>

</message>

func (*Conn) SendGroupChatMessage

func (c *Conn) SendGroupChatMessage(to, msg string) error

Send an Im message to group chat.

func (*Conn) SendMediatedMucInvitation

func (c *Conn) SendMediatedMucInvitation(to string, roomJid string, reason string) error

<message

  from='crone1@shakespeare.lit/desktop'
  id='nzd143v8'
  to='coven@chat.shakespeare.lit'>
<x xmlns='http://jabber.org/protocol/muc#user'>
  <invite to='hecate@shakespeare.lit'>
    <reason>
      Hey Hecate, this is the place for all good witches!
    </reason>
  </invite>
</x>

</message>

func (*Conn) SetAffiliation

func (c *Conn) SetAffiliation(roomJid, jid string, affiliation int) error

func (*Conn) SetOffLine

func (c *Conn) SetOffLine() error

func (*Conn) SetRole

func (c *Conn) SetRole(roomJid, jid string, role int) error

func (*Conn) SignalPresence

func (c *Conn) SignalPresence(state string) error

func (*Conn) SliencePresence

func (c *Conn) SliencePresence() error

type DiscoveryFeature

type DiscoveryFeature struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info feature"`
	Var     string   `xml:"var,attr"`
}

type DiscoveryIdentity

type DiscoveryIdentity struct {
	XMLName  xml.Name `xml:"http://jabber.org/protocol/disco#info identity"`
	Category string   `xml:"category,attr"`
	Type     string   `xml:"type,attr"`
	Name     string   `xml:"name,attr"`
}

type DiscoveryReply

type DiscoveryReply struct {
	XMLName    xml.Name `xml:"http://jabber.org/protocol/disco#info query"`
	Identities []DiscoveryIdentity
	Features   []DiscoveryFeature
}

type EmptyReply

type EmptyReply struct {
}

An EmptyReply results in in no XML.

type ErrorBadRequest

type ErrorBadRequest struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-request"`
}

ErrorBadRequest reflects a bad-request stanza. See http://xmpp.org/rfcs/rfc6120.html#stanzas-error-conditions-bad-request

type ErrorReply

type ErrorReply struct {
	XMLName xml.Name    `xml:"error"`
	Type    string      `xml:"type,attr"`
	Error   interface{} `xml:"error"`
}

ErrorReply reflects an XMPP error stanza. See http://xmpp.org/rfcs/rfc6120.html#stanzas-error-syntax

type Handler

type Handler interface {
	RecvMsg(msg *ClientMessage)
	RecvPresence(pres *ClientPresence)
}

type MucPresenceItem

type MucPresenceItem struct {
	Affiliation string `xml:"affiliation,attr"`
	Role        string `xml:"role,attr"`
	Jid         string `xml:"jid,attr"`
}

type Paused

type Paused struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates paused"`
}

type PresenceC

type PresenceC struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/caps c"`
	Node    string   `xml:"node,attr"`
}

type PresenceX

type PresenceX struct {
	XMLName xml.Name        `xml:"jabber:client x`
	Item    MucPresenceItem `xml:"item"`
}

type Roster

type Roster struct {
	XMLName xml.Name      `xml:"jabber:iq:roster query"`
	Item    []RosterEntry `xml:"item"`
}

type RosterEntry

type RosterEntry struct {
	Jid          string   `xml:"jid,attr"`
	Subscription string   `xml:"subscription,attr"`
	Name         string   `xml:"name,attr"`
	Group        []string `xml:"group"`
}

type RosterRequest

type RosterRequest struct {
	XMLName xml.Name          `xml:"jabber:iq:roster query"`
	Item    RosterRequestItem `xml:"item"`
}

RosterRequest is used to request that the server update the user's roster. See RFC 6121, section 2.3.

type RosterRequestItem

type RosterRequestItem struct {
	Jid          string   `xml:"jid,attr"`
	Subscription string   `xml:"subscription,attr"`
	Name         string   `xml:"name,attr"`
	Group        []string `xml:"group"`
}

type Stanza

type Stanza struct {
	Name  xml.Name
	Value interface{}
}

Stanza represents a message from the XMPP server.

type VersionQuery

type VersionQuery struct {
	XMLName xml.Name `xml:"jabber:iq:version query"`
}

type VersionReply

type VersionReply struct {
	XMLName xml.Name `xml:"jabber:iq:version query"`
	Name    string   `xml:"name"`
	Version string   `xml:"version"`
	OS      string   `xml:"os"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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