## BSender

BSender — sends Blinkenlights packets

## Synopsis

    struct      BSender;
    BSender*    b_sender_new                    (void);
    gboolean    b_sender_add_recipient          (BSender *sender,
                                                 const gchar *host,
                                                 gint port,
                                                 GError **error);
    gboolean    b_sender_remove_recipient       (BSender *sender,
                                                 const gchar *host,
                                                 gint port,
                                                 GError **error);
    GList*      b_sender_list_recipients        (BSender *sender);
    gboolean    b_sender_configure              (BSender *sender,
                                                 gint width,
                                                 gint height,
                                                 gint channels,
                                                 gint maxval);
    gboolean    b_sender_send_frame             (BSender *sender,
                                                 const guchar *data);

## Object Hierarchy

      GObject
       +----BSender

## Description

The BSender object sends Blinkenlights UDP packets to a number of recipients. Recipients can be added and removed at run-time.

## Details

### struct BSender

    struct BSender;

The BSender struct is considered private.

### b_sender_new ()

    BSender*    b_sender_new                    (void);

Creates a new BSender object.

Returns : | a newly allocated BSender object

### b_sender_add_recipient ()

    gboolean    b_sender_add_recipient          (BSender *sender,
                                                 const gchar *host,
                                                 gint port,
                                                 GError **error);

Tries to resolve `host` and adds it to the `sender`'s list of recipients.

`sender` : | a BSender object
`host` : | a hostname or IP address
`port` : | a UDP port number
`error` : | location to store the error occuring, or `NULL` to ignore errors
Returns : | `TRUE` if the recipient was successfully added, `FALSE` otherwise

### b_sender_remove_recipient ()

    gboolean    b_sender_remove_recipient       (BSender *sender,
                                                 const gchar *host,
                                                 gint port,
                                                 GError **error);

Removes all recipients with matching host and port from the `sender`'s list of recipients.

`sender` : | a BSender object
`host` : | a hostname or IP address
`port` : | a UDP port number
`error` : | location to store the error occuring, or `NULL` to ignore errors
Returns : | `TRUE` if at least one matching recipient was found and removed, `FALSE` otherwise

### b_sender_list_recipients ()

    GList*      b_sender_list_recipients        (BSender *sender);

Creates a list of strings that describe the `senders` recipients. You should free the strings as well as the list when it is no longer needed.

`sender` : | a BSender object
Returns : | a newly allocated GList of newly allocated strings

### b_sender_configure ()

    gboolean    b_sender_configure              (BSender *sender,
                                                 gint width,
                                                 gint height,
                                                 gint channels,
                                                 gint maxval);

Prepares `sender` to send Blinkenlights UDP packets with the given parameters.

`sender` : | a BSender object
`width` : | number of pixels per row
`height` : | number of pixels per column
`channels` : | number of channels per pixel
`maxval` : | the maximum value
Returns : | `TRUE` if `sender` was successfully reconfigured, `FALSE` otherwise

### b_sender_send_frame ()

    gboolean    b_sender_send_frame             (BSender *sender,
                                                 const guchar *data);

Sends Blinkenlights packets to all recipients registered with `sender`. The `data` should match the values of the last call to b_sender_configure() for `sender`.

`sender` : | a Bsender object
`data` : | the frame data to send
Returns : | `FALSE` in case of a fatal error, `TRUE` otherwise

## See Also

BReceiver, BPacket