]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
Added callback for peer discovery
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 11 May 2009 01:28:32 +0000 (03:28 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 11 May 2009 01:28:32 +0000 (03:28 +0200)
By using this callback, an application can react on peer discovery.
Note: Peers are discovered by broadcasting "HELLO" packets.

src/forb.h
src/iop.c

index 827c4550c29ad53d13b62ce259b149d5283f1007..e8d227ee8de9e98f6ecbebe4c66a9e1d7a1c3906 100644 (file)
@@ -156,6 +156,9 @@ typedef struct forb_interface forb_interface_t;
 
 typedef struct forb_init_attr {
        char *orb_id;           /**< Name of the FORB used for debugging purposes */
+       void (*peer_discovery_callback)(const forb_orb peer_orb, const char *orb_id);
+       void (*peer_dead_callback)(const forb_orb peer_orb, const char *orb_id);
+
 } forb_init_attr_t;
 
 /** 
index 2c3cdb42a0a5d7c823d092c3fad81906fea0ab20..620ae8437f516715dbf4dc8791799e2cc03ad3f2 100644 (file)
--- a/src/iop.c
+++ b/src/iop.c
@@ -400,6 +400,11 @@ void new_peer_discovered(forb_port_t *port, forb_peer_t *peer,
                          forb_server_id_to_string(str, &peer->server_id, sizeof(str)),
                          orb_id);
        }
+       if (forb->attr.peer_discovery_callback) {
+               forb_orb peer_orb = forb_object_new(forb->orb, &peer->server_id, 0);
+               forb->attr.peer_discovery_callback(peer_orb, orb_id);
+               forb_object_release(peer_orb);
+       }
        forb_peer_put(peer);
 
        /* Broadcast our hello packet now */