| Class | DBus::Binding::DBusServer |
| In: |
ruby-dbus.c
|
| Parent: | Object |
A DBusServer listens for and handles connections from clients.
This class isn’t particularly useful right now, as it does not provide new connection, watch, and timeout callback functionality yet.
Creates a new server instance listening for connections on the given address.
See DBusConnection#new for details on the format of the address.
/*
* call-seq:
* listen(address) => server
*
* Creates a new server instance listening for connections on the given
* address.
*
* See DBusConnection#new for details on the format of the address.
*/
static VALUE
cDBusServer_listen(VALUE klass, VALUE address)
{
DBusServer *server = NULL;
RDBUS_TRY(server = dbus_server_listen(StringValuePtr(address), &error));
RDBUS_RAISE_IF(server == NULL, "failed to create DBusServer");
return SERVER_NEW_TAKE_OWNERSHIP(server);
}
Creates a new server instance listening for connections on the given address.
See DBusConnection#new for details on the format of the address.
/*
* call-seq:
* listen(address) => server
*
* Creates a new server instance listening for connections on the given
* address.
*
* See DBusConnection#new for details on the format of the address.
*/
static VALUE
cDBusServer_listen(VALUE klass, VALUE address)
{
DBusServer *server = NULL;
RDBUS_TRY(server = dbus_server_listen(StringValuePtr(address), &error));
RDBUS_RAISE_IF(server == NULL, "failed to create DBusServer");
return SERVER_NEW_TAKE_OWNERSHIP(server);
}
Releases the server’s address and stops listening for new clients.
/*
* call-seq:
* disconnect => nil
*
* Releases the server's address and stops listening for new clients.
*/
static VALUE
cDBusServer_disconnect(VALUE self)
{
dbus_server_disconnect(SERVER_GET(self));
return Qnil;
}
Returns the address the server is listening on.
/*
* call-seq:
* get_address => address
*
* Returns the address the server is listening on.
*/
static VALUE
cDBusServer_get_address(VALUE self)
{
char *address = NULL;
VALUE address_r;
address = dbus_server_get_address(SERVER_GET(self));
if (address == NULL)
return Qnil;
address_r = rb_str_new2(address);
dbus_free(address);
return address_r;
}
Returns true if the server is still listening for new clients.
/*
* call-seq:
* get_is_connected => true|false
*
* Returns +true+ if the server is still listening for new clients.
*/
static VALUE
cDBusServer_get_is_connected(VALUE self)
{
if (dbus_server_get_is_connected(SERVER_GET(self)))
return Qtrue;
return Qfalse;
}
Sets up the dispatching of the server to integrate with the GLIB main loop.
/*
* call-seq:
* setup_with_g_main => nil
*
* Sets up the dispatching of the server to integrate with the GLIB main
* loop.
*/
static VALUE
cDBusServer_setup_with_g_main(VALUE self)
{
dbus_server_setup_with_g_main(SERVER_GET(self), NULL);
return Qnil;
}