Strophe  0.8
XMPP client library
Functions
Connection management

Functions

xmpp_conn_t * xmpp_conn_new (xmpp_ctx_t *const ctx)
 Create a new Strophe connection object.
xmpp_conn_t * xmpp_conn_clone (xmpp_conn_t *const conn)
 Clone a Strophe connection object.
int xmpp_conn_release (xmpp_conn_t *const conn)
 Release a Strophe connection object.
const char * xmpp_conn_get_jid (const xmpp_conn_t *const conn)
 Get the JID which is or will be bound to the connection.
const char * xmpp_conn_get_bound_jid (const xmpp_conn_t *const conn)
 Get the JID discovered during binding time.
void xmpp_conn_set_jid (xmpp_conn_t *const conn, const char *const jid)
 Set the JID of the user that will be bound to the connection.
const char * xmpp_conn_get_pass (const xmpp_conn_t *const conn)
 Get the password used for authentication of a connection.
void xmpp_conn_set_pass (xmpp_conn_t *const conn, const char *const pass)
 Set the password used to authenticate the connection.
xmpp_ctx_t * xmpp_conn_get_context (xmpp_conn_t *const conn)
 Get the strophe context that the connection is associated with.
int xmpp_connect_client (xmpp_conn_t *const conn, const char *const altdomain, unsigned short altport, xmpp_conn_handler callback, void *const userdata)
 Initiate a connection to the XMPP server.
void xmpp_disconnect (xmpp_conn_t *const conn)
 Initiate termination of the connection to the XMPP server.
void xmpp_send (xmpp_conn_t *const conn, xmpp_stanza_t *const stanza)
 Send an XML stanza to the XMPP server.

Function Documentation

xmpp_conn_t* xmpp_conn_new ( xmpp_ctx_t *const  ctx)

Create a new Strophe connection object.

Parameters:
ctxa Strophe context object
Returns:
a Strophe connection object or NULL on an error
xmpp_conn_t* xmpp_conn_clone ( xmpp_conn_t *const  conn)

Clone a Strophe connection object.

Parameters:
conna Strophe connection object
Returns:
the same conn object passed in with its reference count incremented by 1
int xmpp_conn_release ( xmpp_conn_t *const  conn)

Release a Strophe connection object.

Decrement the reference count by one for a connection, freeing the connection object if the count reaches 0.

Parameters:
conna Strophe connection object
Returns:
TRUE if the connection object was freed and FALSE otherwise
const char* xmpp_conn_get_jid ( const xmpp_conn_t *const  conn)

Get the JID which is or will be bound to the connection.

Parameters:
conna Strophe connection object
Returns:
a string containing the full JID or NULL if it has not been set
const char* xmpp_conn_get_bound_jid ( const xmpp_conn_t *const  conn)

Get the JID discovered during binding time.

This JID will contain the resource used by the current connection. This is useful in the case where a resource was not specified for binding.

Parameters:
conna Strophe connection object.
Returns:
a string containing the full JID or NULL if it's not been discovered
void xmpp_conn_set_jid ( xmpp_conn_t *const  conn,
const char *const  jid 
)

Set the JID of the user that will be bound to the connection.

If any JID was previously set, it will be discarded. This should not be be used after a connection is created. The function will make a copy of the JID string. If the supllied JID is missing the node, SASL ANONYMOUS authentication will be used.

Parameters:
conna Strophe connection object
jida full or bare JID
const char* xmpp_conn_get_pass ( const xmpp_conn_t *const  conn)

Get the password used for authentication of a connection.

Parameters:
conna Strophe connection object
Returns:
a string containing the password or NULL if it has not been set
void xmpp_conn_set_pass ( xmpp_conn_t *const  conn,
const char *const  pass 
)

Set the password used to authenticate the connection.

If any password was previously set, it will be discarded. The function will make a copy of the password string.

Parameters:
conna Strophe connection object
passthe password
xmpp_ctx_t* xmpp_conn_get_context ( xmpp_conn_t *const  conn)

Get the strophe context that the connection is associated with.

Parameters:
conna Strophe connection object
Returns:
a Strophe context
int xmpp_connect_client ( xmpp_conn_t *const  conn,
const char *const  altdomain,
unsigned short  altport,
xmpp_conn_handler  callback,
void *const  userdata 
)

Initiate a connection to the XMPP server.

This function returns immediately after starting the connection process to the XMPP server, and notifiations of connection state changes will be sent to the callback function. The domain and port to connect to are usually determined by an SRV lookup for the xmpp-client service at the domain specified in the JID. If SRV lookup fails, altdomain and altport will be used instead if specified.

Parameters:
conna Strophe connection object
altdomaina string with domain to use if SRV lookup fails. If this is NULL, the domain from the JID will be used.
altportan integer port number to use if SRV lookup fails. If this is 0, the default port (5222) will be assumed.
callbacka xmpp_conn_handler callback function that will receive notifications of connection status
userdataan opaque data pointer that will be passed to the callback
Returns:
0 on success and -1 on an error
void xmpp_disconnect ( xmpp_conn_t *const  conn)

Initiate termination of the connection to the XMPP server.

This function starts the disconnection sequence by sending </stream:stream> to the XMPP server. This function will do nothing if the connection state is CONNECTING or CONNECTED.

Parameters:
conna Strophe connection object
void xmpp_send ( xmpp_conn_t *const  conn,
xmpp_stanza_t *const  stanza 
)

Send an XML stanza to the XMPP server.

This is the main way to send data to the XMPP server. The function will terminate without action if the connection state is not CONNECTED.

Parameters:
conna Strophe connection object
stanzaa Strophe stanza object