Version: v0.0.0-...-823dbf3 Latest Latest

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

Go to latest
Published: Apr 9, 2022 License: BSD-2-Clause Imports: 27 Imported by: 0



Package client is a high-level XMPP client implementation.



This section is empty.


This section is empty.


This section is empty.


type Client

type Client struct {
	// contains filtered or unexported fields

Client represents an XMPP client.

func New

func New(j jid.JID, logger, debug *log.Logger, opts ...Option) *Client

New creates a new XMPP client but does not attempt to negotiate a session or send an initial presence, etc.

func (*Client) Away

func (c *Client) Away(ctx context.Context) error

Away sets the status to away.

func (*Client) Bookmarks

func (c *Client) Bookmarks(ctx context.Context) error

Bookmarks fetches the users list of bookmarked chat rooms.

func (*Client) Busy

func (c *Client) Busy(ctx context.Context) error

Busy sets the status to busy.

func (*Client) Disco

func (c *Client) Disco(j jid.JID) (disco.Info, error)

Disco fetches the service discovery information associated with the provided JID by sending an event capable of returning the results over a channel.

func (*Client) Handler

func (c *Client) Handler(h func(interface{}))

Handler configures a handler function to be used for events emitted by the client.

For a list of events that any handler function may handle, see the event package.

func (*Client) JoinMUC

func (c *Client) JoinMUC(ctx context.Context, room jid.JID) error

JoinMUC joins a multi-user chat, or rejoins it if it was already joined.

func (*Client) LeaveMUC

func (c *Client) LeaveMUC(ctx context.Context, room jid.JID, reason string) error

LeaveMUC exits the given multi-user chat..

func (*Client) Offline

func (c *Client) Offline() error

Offline logs the client off.

func (*Client) Online

func (c *Client) Online(ctx context.Context) error

Online sets the status to online. The provided context is used if the client was previously offline and we have to re-establish the session, so if it includes a timeout make sure to account for the fact that we might reconnect.

func (*Client) Roster

func (c *Client) Roster(ctx context.Context) error

Roster requests the users contact list.

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, msg event.ChatMessage) (event.ChatMessage, error)

SendMessage encodes the provided message to the output stream and adds a request for a receipt. It then blocks until the message receipt is received, or the context is canceled.

func (*Client) Timeout

func (c *Client) Timeout() time.Duration

Timeout is the read/write timeout used by the client.

type Option

type Option func(*Client)

Option is used to configure a client.

func Dialer

func Dialer(d *dial.Dialer) Option

Dialer sets the dialer used to make the underlying XMPP connections.

If this option is not provided, a default TLS dialer is used with the servername set to the domainpart of the JID.

func NoTLS

func NoTLS(v bool) Option

NoTLS configures the client to use a plain connection. This should only be used for debugging.

func Password

func Password(getPass func(context.Context) (string, error)) Option

Password is a function that will be used to fetch the password for the account when the client connects.

The getPass function will be called every time the password is required, including reconnects so you may wish to use a memoized function. If the option is not provided or a nil function is used, the password will always be an empty string.

func RosterVer

func RosterVer(ver string) Option

RosterVer sets the last seen and stored roster version.

func Tee

func Tee(in io.Writer, out io.Writer) Option

Tee mirrors XML from the XMPP stream to the underlying writers similar to the tee(1) command.

If a nil writer is provided for either argument, that stream will not be mirrored.

func Timeout

func Timeout(timeout time.Duration) Option

Timeout sets a timeout for reads and writes from the client. If no timeout is provided, the default is 30 seconds.


Path Synopsis
Package event contains events that may be emited by the client.
Package event contains events that may be emited by the client.

Jump to

Keyboard shortcuts

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