Top | ![]() |
![]() |
![]() |
![]() |
InfXmppManager stores InfXmppConnection objects and allows to look them up by the IP address and port number of their underlaying InfTcpConnections. This can be used to reuse existing network connections instead of creating new ones.
Each object which needs to make connections should be passed a
InfXmppManager. Then, when making a connection to a certain address/port
pair, it should first look in the XMPP manager whether there is already
an existing connection to the destination host, via
inf_xmpp_manager_lookup_connection_by_address()
. If there is, it should
use it (maybe reopen it if it is closed). Otherwise, it should create a
new connection and add it to the XMPP manager via
inf_xmpp_manager_add_connection()
for others to use.
The XMPP manager can also handle connections whose address is still to be looked up. Such connections are looked up by the hostname given to the name resolver. Once the hostname has been looked up, and if another connection with the same address and port number exists already, the new connection is removed in favor of the already existing one.
InfXmppManager *
inf_xmpp_manager_new (void
);
Creates a new xmpp manager.
[constructor]
InfXmppConnection * inf_xmpp_manager_lookup_connection_by_address (InfXmppManager *manager
,const InfIpAddress *address
,guint port
);
Looks for a InfXmppConnection contained in manager
whose underlaying
InfTcpConnection has the given address and port set. Returns NULL
if
there is no such connection.
This function may also return a closed connection. You can then attempt to
reopen it, or remove it from the manager using
inf_xmpp_manager_remove_connection()
when that fails.
manager |
||
address |
The remote InfIpAddress of the connection to look for. |
|
port |
The remote port number of the connection to look for. |
A InfXmppConnection with the given
address and port, or NULL
if not found.
[transfer none][allow-none]
InfXmppConnection * inf_xmpp_manager_lookup_connection_by_hostname (InfXmppManager *manager
,const gchar *hostname
,const gchar *service
,const gchar *srv
);
Looks for a InfXmppConnection contained in manager
whose underlaying
InfTcpConnection has a InfNameResolver with the given properties.
This function may also return a closed connection. You can then attempt to
reopen it, or remove it from the manager using
inf_xmpp_manager_remove_connection()
when that fails.
manager |
||
hostname |
The remote hostname to look for. |
|
service |
The service string of the connection to look for. |
[allow-none] |
srv |
The SRV record corresponding to the connection. |
[allow-none] |
A InfXmppConnection with the given
hostname, service and srv, or NULL
if not found.
[transfer none][allow-none]
gboolean inf_xmpp_manager_contains_connection (InfXmppManager *manager
,InfXmppConnection *connection
);
Returns whether connection
is contained in manager
.
void inf_xmpp_manager_add_connection (InfXmppManager *manager
,InfXmppConnection *connection
);
Adds the given connection to manager
so that it is found by
inf_xmpp_manager_lookup_connection_by_address()
,
inf_xmpp_manager_lookup_connection_by_hostname()
and
inf_xmpp_manager_contains_connection()
.
void inf_xmpp_manager_remove_connection (InfXmppManager *manager
,InfXmppConnection *connection
);
Removes the given connection from manager
.
struct InfXmppManager;
InfXmppManager is an opaque data type. You should only access it via the public API functions.
struct InfXmppManagerClass { void(*connection_added)(InfXmppManager* manager, InfXmppConnection* connection); void(*connection_removed)(InfXmppManager* manager, InfXmppConnection* connection, InfXmppConnection* replaced_by); };
This structure contains the default signal handlers for InfXmppManager.
Default signal handler for the “connection-added” signal. |
||
Default signal handler for the “connection-removed” signal. |
“connection-added”
signalvoid user_function (InfXmppManager *xmpp_manager, InfXmppConnection *connection, gpointer user_data)
This signal is emitted whenever a new connection has been added to the
InfXmppManager, via inf_xmpp_manager_add_connection()
.
xmpp_manager |
The InfXmppManager emitting the signal. |
|
connection |
The InfXmppConnection that was added to |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“connection-removed”
signalvoid user_function (InfXmppManager *infxmppmanager, InfXmppConnection *arg1, InfXmppConnection *arg2, gpointer user_data)
Flags: Run Last