-static void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
- static struct timeval tv0;
- struct timeval tv;
-
- if(tv0.tv_sec == 0) {
- gettimeofday(&tv0, NULL);
- }
-
- gettimeofday(&tv, NULL);
- fprintf(stderr, "%u.%.03u ", (unsigned int)(tv.tv_sec - tv0.tv_sec), (unsigned int)tv.tv_usec / 1000);
-
- if(mesh) {
- fprintf(stderr, "(%s) ", mesh->name);
- }
-
- fprintf(stderr, "[%d] %s\n", level, text);
-}
-
-static void server_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
- (void)data;
-
- // We expect no data from clients, apart from disconnections.
- assert(len == 0);
-
- meshlink_channel_t **c = mesh->priv;
- int count = 0;
-
- for(int i = 0; i < 3; i++) {
- if(c[i] == channel) {
- c[i] = NULL;
- fprintf(stderr, "server received channel %d closure from %s\n", i, channel->node->name);
-
- meshlink_channel_close(mesh, channel);
- }
-
- if(c[i]) {
- count++;
- }
- }
+static void client_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
+ assert(mesh->priv);
+ struct client *client = mesh->priv;