xmpp

package module
v0.0.0-...-2413d0d Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2015 License: BSD-3-Clause Imports: 17 Imported by: 2

README

go-xmpp

go xmpp library (original was written by russ cox )

Documentation

Overview

Package xmpp implements a simple Google Talk client using the XMPP protocol described in RFC 3920 and RFC 3921.

TODO(flo):

  • support password protected MUC rooms
  • cleanup signatures of join/leave functions

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig tls.Config

Default TLS configuration options

Functions

This section is empty.

Types

type Chat

type Chat struct {
	To     string
	From   string
	Type   string
	Text   string
	Roster Roster
	Other  []string
}

Chat is an incoming or outgoing XMPP chat message.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds XMPP connection opitons

func NewClient

func NewClient(host, user, passwd string, debug bool) (*Client, error)

NewClient creates a new connection to a host given as "hostname" or "hostname:port". If host is not specified, the DNS SRV should be used to find the host from the domainpart of the JID. Default the port to 5222.

func NewClientNoTLS

func NewClientNoTLS(host, user, passwd string, debug bool) (*Client, error)

NewClientNoTLS creates a new client without TLS

func (*Client) ApproveSubscription

func (c *Client) ApproveSubscription(jid string)

func (*Client) Close

func (c *Client) Close() error

Close closes the XMPP connection

func (*Client) IsEncrypted

func (c *Client) IsEncrypted() bool

IsEncrypted will return true if the client is connected using a TLS transport, either because it used. TLS to connect from the outset, or because it successfully used STARTTLS to promote a TCP connection to TLS.

func (*Client) JoinMUC

func (c *Client) JoinMUC(jid, nick string)

xep-0045 7.2

func (*Client) JoinProtectedMUC

func (c *Client) JoinProtectedMUC(jid, nick string, password string)

xep-0045 7.2.6

func (*Client) LeaveMUC

func (c *Client) LeaveMUC(jid string)

xep-0045 7.14

func (*Client) PingC2S

func (c *Client) PingC2S(jid, server string)

func (*Client) PingS2S

func (c *Client) PingS2S(fromServer, toServer string)

func (*Client) Recv

func (c *Client) Recv() (stanza interface{}, err error)

Recv waits to receive the next XMPP stanza. Return type is either a presence notification or a chat message.

func (*Client) RequestSubscription

func (c *Client) RequestSubscription(jid string)

func (*Client) RevokeSubscription

func (c *Client) RevokeSubscription(jid string)

func (*Client) Roster

func (c *Client) Roster() error

Roster asks for the chat roster.

func (*Client) Send

func (c *Client) Send(chat Chat) (n int, err error)

Send sends the message wrapped inside an XMPP message stanza body.

func (*Client) SendHtml

func (c *Client) SendHtml(chat Chat) (n int, err error)

SendHtml sends the message as HTML as defined by XEP-0071

func (*Client) SendOrg

func (c *Client) SendOrg(org string) (n int, err error)

SendOrg sends the original text without being wrapped in an XMPP message stanza.

type Contact

type Contact struct {
	Remote string
	Name   string
	Group  []string
}
type Cookie uint64

Cookie is a unique XMPP session identifier

type Options

type Options struct {
	// Host specifies what host to connect to, as either "hostname" or "hostname:port"
	// If host is not specified, the  DNS SRV should be used to find the host from the domainpart of the JID.
	// Default the port to 5222.
	Host string

	// User specifies what user to authenticate to the remote server.
	User string

	// Password supplies the password to use for authentication with the remote server.
	Password string

	// Resource specifies an XMPP client resource, like "bot", instead of accepting one
	// from the server.  Use "" to let the server generate one for your client.
	Resource string

	// TLS Config
	TLSConfig *tls.Config

	// InsecureAllowUnencryptedAuth permits authentication over a TCP connection that has not been promoted to
	// TLS by STARTTLS; this could leak authentication information over the network, or permit man in the middle
	// attacks.
	InsecureAllowUnencryptedAuth bool

	// NoTLS directs go-xmpp to not use TLS initially to contact the server; instead, a plain old unencrypted
	// TCP connection should be used. (Can be combined with StartTLS to support STARTTLS-based servers.)
	NoTLS bool

	// StartTLS directs go-xmpp to STARTTLS if the server supports it; go-xmpp will automatically STARTTLS
	// if the server requires it regardless of this option.
	StartTLS bool

	// Debug output
	Debug bool

	// Use server sessions
	Session bool

	// Presence Status
	Status string

	// Status message
	StatusMessage string
}

Options are used to specify additional options for new clients, such as a Resource.

func (Options) NewClient

func (o Options) NewClient() (*Client, error)

NewClient establishes a new Client connection based on a set of Options.

type Presence

type Presence struct {
	From string
	To   string
	Type string
	Show string
}

Presence is an XMPP presence notification.

type Roster

type Roster []Contact

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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