![]() |
![]() |
![]() |
Dee Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
#include <dee.h> #define DEE_PEER_DBUS_IFACE struct DeePeer; struct DeePeerClass; DeePeer * dee_peer_new (const gchar *swarm_name
); const gboolean dee_peer_is_swarm_leader (DeePeer *self
); const gchar * dee_peer_get_swarm_leader (DeePeer *self
); const gchar * dee_peer_get_swarm_name (DeePeer *self
); DeePeerPrivate;
DeePeer allows you to build objects that can rendevouz on DBus without the need for an central registration service. Think of it like peer-to-peer for your application. The DBus session bus will also implicitly elect a swarm leader - namely the one owning the swarm name on the bus, but it's up to the consumer of this API to determine whether swarm leadership has any concrete responsibilities associated.
Peers find eachother through a well-known "swarm-name", which is a well known DBus name, such as: org.myapp.MyPeers. Choose a namespaced name that would not normally be used outside of your program.
For example:
{ DeePeer *peer; peer = g_object_new (DBUS_TYPE_PEER, "swarm-name", "org.myapp.MyPeers", NULL); g_signal_connect (peer, "peer-found", G_CALLBACK (on_peer_found), NULL); g_signal_connect (peer, "peer-lost", G_CALLBACK (on_peer_lost), NULL); }
struct DeePeer;
All fields in the DeePeer structure are private and should never be accessed directly
struct DeePeerClass { /*< signals >*/ void (*connected) (DeePeer *peer, const gchar *peer_name); void (*peer_found) (DeePeer *peer, const gchar *name); void (*peer_lost) (DeePeer *peer, const gchar *name); /*< vtable >*/ };
DeePeer * dee_peer_new (const gchar *swarm_name
);
Create a new DeePeer. The peer will immediately connect to the swarm and start the peer discovery.
|
The name of the swarm to join. Fx "org.example.DataProviders" |
Returns : |
A newly constructed DeePeer.
Free with g_object_unref() . [transfer full]
|
const gchar * dee_peer_get_swarm_leader (DeePeer *self
);
Gets the unique DBus address of the current swarm leader.
This function can only be used after dee_peer_connect()
has been called.
const gchar * dee_peer_get_swarm_name (DeePeer *self
);
Gets the unique name for this swarm. The swarm leader is the Peer owning this name on the session bus.
|
a DeePeer |
Returns : |
The swarm name |
"swarm-leader"
property"swarm-leader" gchar* : Read
Unique DBus address of the swarm leader.
Default value: NULL
"swarm-name"
property"swarm-name" gchar* : Read / Write / Construct
Well-known name to find other peers with.
Default value: NULL
"peer-found"
signalvoid user_function (DeePeer *self,
gchar *name,
gpointer user_data) : Run Last
Connect to this signal to be notified of existing and new peers that are in your swarm.
|
the DeePeer on which the signal is emitted |
|
the DBus name of the object found |
|
user data set when the signal handler was connected. |
"peer-lost"
signalvoid user_function (DeePeer *self,
gchar *name,
gpointer user_data) : Run Last
Connect to this signal to be notified when peers disconnect from the swarm
|
the DeePeer on which the signal is emitted |
|
the DBus name of the object that disconnected |
|
user data set when the signal handler was connected. |