BLib Reference Manual |
---|
BReceiver — receives Blinkenlights packets
struct BReceiver; gboolean (*BReceiverCallback) (BReceiver *receiver, BPacket *packet, gpointer callback_data); BReceiver* b_receiver_new (BReceiverCallback callback, gpointer callback_data); gboolean b_receiver_listen (BReceiver *receiver, gint port); gboolean b_receiver_listen_fd (BReceiver *receiver, gint fd); void b_receiver_stop (BReceiver *receiver);
"callback" gpointer : Write / Construct Only "callback-data" gpointer : Write / Construct Only
The BReceiver object listens for Blinkenlights UDP packets. For each frame that matches the receiver configuration, a user-defined callback is called with the received packet.
gboolean (*BReceiverCallback) (BReceiver *receiver, BPacket *packet, gpointer callback_data);
The function that gets called to dispatch incoming packets.
receiver : | the BReceiver object that received the packet |
packet : | the received BPacket converted to host byteorder |
callback_data : | the data that was passed to b_receiver_new() |
Returns : | TRUE if you want to be called again |
BReceiver* b_receiver_new (BReceiverCallback callback, gpointer callback_data);
Creates a new BReceiver object.
callback : | the function to call when a new frame arrives |
callback_data : | data to pass to the callback |
Returns : | a newly allocate BReceiver object |
gboolean b_receiver_listen (BReceiver *receiver, gint port);
Causes the receiver to start to listen to the specified UDP port. For each successfully received Blinkenlights packet, the packet will be converted to host byteorder and the callback that was specified on b_receiver_new() will be called.
receiver : | a BReceiver object |
port : | the UDP port to listen to |
Returns : | TRUE if the receiver listens to port, FALSE otherwise |
gboolean b_receiver_listen_fd (BReceiver *receiver, gint fd);
Causes the receiver to start to listen to the given file descriptor. This function is rarely useful, it is used internally by BProxyClient.
receiver : | a BReceiver object |
fd : | a file descriptor |
Returns : | TRUE on success |
<< BProxyServer | BSender >> |