The Pedro C-library provides support for writing Pedro clients. It is built on top of the glib library.
Client is an opaque datatype used to store information about a Pedro
client. The intention is to use
g_main_loop_run with the callback
declared in the creation of the client called each time data is sent to the
client from the Pedro server. The program
consumer.c in the examples
directory is a simple example using this approach.
The following functions define the client interface.
Client* client_new(void (*cb) (char*, gpointer, gpointer), gpointer user_data);
cb(user defined) takes the data from the server, the rock specified in the matching subscription and a pointer to user data and is called each time data arrives from the server. The last argument,
user_data, is a pointer to the user data used as the third agument to the callback.
Client* client_new_full(int port, char* hostname, void (*cb) (char*, gpointer, gpointer), gpointer user_data);
void client_destroy(Client* client);
int subscribe(Client* client, char* term, char* goal, gpointer rock);
gboolean unsubscribe(Client* client, guint id);
gboolean notify(Client* client, char* term);
gboolean register_name(Client* client, char* name);
gboolean deregister_name(Client* client);
gboolean p2p(Client* client, char* toaddr, char* msg);