Top | ![]() |
![]() |
![]() |
![]() |
GSList * | dee_peer_get_connections () |
const gchar * | dee_peer_get_swarm_leader () |
const gchar * | dee_peer_get_swarm_name () |
gboolean | dee_peer_is_swarm_leader () |
gboolean | dee_peer_is_swarm_owner () |
gchar ** | dee_peer_list_peers () |
DeePeer * | dee_peer_new () |
gchar * | swarm-leader | Read |
gchar * | swarm-name | Read / Write / Construct |
gboolean | swarm-owner | Read / Write / Construct Only |
void | connection-acquired | Run Last |
void | connection-closed | Run Last |
void | peer-found | Run Last |
void | peer-lost | Run Last |
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:
1 2 3 4 5 6 7 8 9 10 11 12 |
{ 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); } |
GSList *
dee_peer_get_connections (DeePeer *self
);
Gets list of GDBusConnection instances used by this DeePeer instance.
const gchar *
dee_peer_get_swarm_leader (DeePeer *self
);
In case this peer is connected to a message bus, gets the unique DBus address of the current swarm leader, otherwise returns id of the leader.
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.
gboolean
dee_peer_is_swarm_owner (DeePeer *self
);
Gets the value of the :swarm-owner property.
Note that this does NOT mean that the peer is leader of the swarm! Check also
dee_peer_is_swarm_leader()
.
gchar **
dee_peer_list_peers (DeePeer *self
);
Gets list of all peers currently in this swarm.
struct DeePeer;
All fields in the DeePeer structure are private and should never be accessed directly
struct DeePeerClass { /*< signals >*/ void (*peer_found) (DeePeer *self, const gchar *name); void (*peer_lost) (DeePeer *self, const gchar *name); void (*connection_acquired) (DeePeer *self, GDBusConnection *connection); void (*connection_closed) (DeePeer *self, GDBusConnection *connection); /*< vtable >*/ const gchar* (*get_swarm_leader) (DeePeer *self); gboolean (*is_swarm_leader) (DeePeer *self); GSList* (*get_connections) (DeePeer *self); gchar** (*list_peers) (DeePeer *self); };
“swarm-leader”
property “swarm-leader” gchar *
Unique DBus address of the swarm leader.
Flags: Read
Default value: NULL
“swarm-name”
property “swarm-name” gchar *
Well-known name to find other peers with.
Flags: Read / Write / Construct
Default value: NULL
“connection-acquired”
signalvoid user_function (DeePeer *deepeer, GDBusConnection *arg1, gpointer user_data)
Flags: Run Last
“connection-closed”
signalvoid user_function (DeePeer *self, GDBusConnection *connection, gpointer user_data)
Connect to this signal to be notified when peers close their GDBusConnection.
self |
the DeePeer on which the signal is emitted |
|
connection |
the closed GDBusConnection |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“peer-found”
signalvoid user_function (DeePeer *self, gchar *name, gpointer user_data)
Connect to this signal to be notified of existing and new peers that are in your swarm.
self |
the DeePeer on which the signal is emitted |
|
name |
the DBus name of the object found |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“peer-lost”
signalvoid user_function (DeePeer *self, gchar *name, gpointer user_data)
Connect to this signal to be notified when peers disconnect from the swarm
self |
the DeePeer on which the signal is emitted |
|
name |
the DBus name of the object that disconnected |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last