## InfCommunicationRegistry InfCommunicationRegistry — Sharing connections between multiple groups |

## Stability Level

Unstable, unless otherwise indicated

## Synopsis

    #include <libinfinity/communication/inf-communication-registry.h>

                        InfCommunicationRegistry;
    struct              InfCommunicationRegistryClass;
    void                inf_communication_registry_register (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfCommunicationMethod *method,
                                                             InfXmlConnection *connection);
    void                inf_communication_registry_unregister
                                                            (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection);
    gboolean            inf_communication_registry_is_registered
                                                            (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection);
    void                inf_communication_registry_send     (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection,
                                                             xmlNodePtr xml);
    void                inf_communication_registry_cancel_messages
                                                            (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection);

## Object Hierarchy

      GObject
       +----InfCommunicationRegistry

## Description

InfCommunicationRegistry provides a way for InfCommunicationMethod implementations to share connections with other groups. Before using a connection, call `inf_communication_registry_register()`. Then, messages can be sent to the group via `inf_communication_registry_send()`.

The InfCommunicationRegistry calls `inf_communication_method_received()` on your method when it received a message for the group, `inf_communication_method_enqueued()` when sending the message cannot be cancelled anymore via `inf_communication_registry_cancel_messages()` and `inf_communication_method_sent()` when the message has been sent.

## Details

### InfCommunicationRegistry

    typedef struct _InfCommunicationRegistry InfCommunicationRegistry;

InfCommunicationRegistry is an opaque data type. You should only access it via the public API functions.

### struct InfCommunicationRegistryClass

    struct InfCommunicationRegistryClass {
    };

This structure does not contain any public fields.

### inf_communication_registry_register ()

    void                inf_communication_registry_register (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfCommunicationMethod *method,
                                                             InfXmlConnection *connection);

Registers connection with `group`. This allows sending messages to `connection` via `inf_communication_registry_send()`. For received messages, `inf_communication_method_received()` is called on `method`.

`connection` must have status `INF_XML_CONNECTION_OPEN`.

`registry` : | A InfCommunicationRegistry.
`group` : | The group for which to register a connection.
`method` : | The InfCommunicationMethod used.
`connection` : | The connection to register.

### inf_communication_registry_unregister ()

    void                inf_communication_registry_unregister
                                                            (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection);

Unregisters `connection` from `group`. Incoming messages are no longer reported to group's method, and `inf_communication_registry_send()` can no longer be called for `connection`.

`registry` : | A InfCommunicationRegistry.
`group` : | The group for which to unregister a connection.
`connection` : | The connection to unregister.

### inf_communication_registry_is_registered ()

    gboolean            inf_communication_registry_is_registered
                                                            (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection);

Returns whether `connection` has been registered for `group` with `inf_communication_registry_register()`.

`registry` : | A InfCommunicationRegistry.
`group` : | The group for which to check whether `connection` is registered.
`connection` : | The connection to check for registration.
Returns : | `TRUE` if `connection` has been registered, or `FALSE` otherwise.

### inf_communication_registry_send ()

    void                inf_communication_registry_send     (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection,
                                                             xmlNodePtr xml);

Sends an XML message to `connection`. `connection` must have been registered with `inf_communication_registry_register()` before. If the message has been sent, `inf_communication_method_sent()` is called on the method the connection was registered with. `inf_communication_method_enqueued()` is called when sending the message can no longer be cancelled via `inf_communication_registry_cancel_messages()`.

This function takes ownership of `xml`.

`registry` : | A InfCommunicationRegistry.
`group` : | The group for which to send the message InfCommunicationGroup.
`connection` : | A registered InfXmlConnection.
`xml` : | The message to send.

### inf_communication_registry_cancel_messages ()

    void                inf_communication_registry_cancel_messages
                                                            (InfCommunicationRegistry *registry,
                                                             InfCommunicationGroup *group,
                                                             InfXmlConnection *connection);

Stops all messages scheduled to be sent to `connection` in `group` from being sent.

`registry` : | A InfCommunicationRegistry.
`group` : | The group for which to cancel messages.
`connection` : | A registered InfXmlConnection.