package obus
Install
Dune Dependency
Authors
Maintainers
Sources
md5=81eb1034c6ef4421a2368a9b352199de
sha512=4b540497188a7d78f4f14f94c6b7fdff47dd06436a34e650ff378dd77bb3e2acb7afd45cd72daf4ddba06e732e9944d560c2882dc37862f1b1f1bb6df37e6205
doc/obus/OBus_bus/index.html
Module OBus_bus
Source
Message buses management
Well-known instances
session ?switch ()
returns a connection to the user session message bus. Subsequent calls to session
will return the same bus. OBus will automatically exit the program when an error happens on the session bus. You can change this behavior by calling OBus_connection.set_on_disconnect
.
Creation
Establish a connection with a message bus. The bus must be accessible with at least one of the given addresses
Register the given connection to a message bus. It has the side effect of requesting a name to the message bus if not already done.
If the connection is a connection to a message bus, created with one of the function of OBus_connection
then register_connection
must be called on it before any other functions.
Function which exit the program as follow:
- if
exn
isOBus_connection.Connection_lost
, it exits the program with a return code of 0
- if
exn
is a fatal error, it prints a message on stderr and exits the program with an exit code of 1
Peer/proxy helpers
get_peer bus name
returns the peer owning the bus name name
. If the service is not activated and is activable, then it is started
get_proxy bus name path
resolves name
with get_peer
and returns a proxy for the object with path path
on this service
Bus names
Same as OBus_connection.name
.
names bus
is the signal holding the set of all names we currently own. It raises Invalid_argument
if the connection is not a connection to a message bus.
hello connection
sends an hello message to the message bus, which returns the unique connection name of the connection. Note that if the hello message has already been sent, it will fail.
Exception raised when a name cannot be owned due to security policies
type request_name_result = [
| `Primary_owner
(*You are now the primary owner of the connection
*)| `In_queue
(*You will get the name when it will be available
*)| `Exists
(*Somebody else already have the name and nobody specified what to do in this case
*)| `Already_owner
(*You already have the name
*)
]
val request_name :
t ->
?allow_replacement:bool ->
?replace_existing:bool ->
?do_not_queue:bool ->
OBus_name.bus ->
request_name_result Lwt.t
Request a name to the bus. This is the way to acquire a well-know name.
All optional parameters default to false
, their meaning are:
allow_replacement
: allow other application to steal this name from youreplace_existing
: replace any existing owner of the namedo_not_queue
: do not queue if not available
Service starting/discovering
Exception raised when a service is not present on a message bus and can not be started automatically
Start a service on the given bus by its name
Returns true
if the service is currently running, i.e. some application offers it on the message bus
List names currently running on the message bus
List services that can be activated. A service is automatically activated when you call one of its method or when you use start_service_by_name
Return the connection unique name of the given service. Raise a Name_has_no_owner
if the given name does not have an owner.
Return the connection unique names of the applications waiting for a name
Messages routing
Note that you should prefer using OBus_match.export
and OBus_match.remove
since they do not add duplicated rules several times.
Exception raised when the program tries to send an invalid match rule. This should never happen since values of type OBus_match.rule
are always valid.
Add a matching rule on a message bus. This means that every message routed on the message bus matching this rule will be sent to us.
It can raise OBus_error.No_memory
.
Remove a match rule from the message bus. It raises Match_rule_not_found
if the rule does not exists
Other
These functions are also offered by the message bus
Signals
This signal is emitted each time the owner of a name (unique connection name or service name) changes.