Documentation ¶
Overview ¶
Package client is a high-level XMPP client implementation.
Index ¶
- type Client
- func (c *Client) Away(ctx context.Context) error
- func (c *Client) Bookmarks(ctx context.Context) error
- func (c *Client) Busy(ctx context.Context) error
- func (c *Client) Disco(j jid.JID) (disco.Info, error)
- func (c *Client) Handler(h func(interface{}))
- func (c *Client) JoinMUC(ctx context.Context, room jid.JID) error
- func (c *Client) LeaveMUC(ctx context.Context, room jid.JID, reason string) error
- func (c *Client) Offline() error
- func (c *Client) Online(ctx context.Context) error
- func (c *Client) Roster(ctx context.Context) error
- func (c *Client) SendMessage(ctx context.Context, msg event.ChatMessage) (event.ChatMessage, error)
- func (c *Client) Timeout() time.Duration
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client represents an XMPP client.
func New ¶
New creates a new XMPP client but does not attempt to negotiate a session or send an initial presence, etc.
func (*Client) Disco ¶
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) Online ¶
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) 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.
type Option ¶
type Option func(*Client)
Option is used to configure a client.
func Dialer ¶
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 ¶
NoTLS configures the client to use a plain connection. This should only be used for debugging.
func Password ¶
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.