Class: DBus::Binding::DBusServer

Inherits:
Object
  • Object
show all
Defined in:
ext/ruby-dbus-server.c,
ext/ruby-dbus-server.c

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listen(address) ⇒ Object

Creates a new server instance listening for connections on the given address.

See DBusConnection#new for details on the format of the address.



50
51
52
53
54
55
56
57
58
# File 'ext/ruby-dbus-server.c', line 50

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);
}

.listen(address) ⇒ Object

Creates a new server instance listening for connections on the given address.

See DBusConnection#new for details on the format of the address.



50
51
52
53
54
55
56
57
58
# File 'ext/ruby-dbus-server.c', line 50

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);
}

Instance Method Details

#disconnectnil

Releases the server’s address and stops listening for new clients.

Returns:

  • (nil)


66
67
68
69
70
71
# File 'ext/ruby-dbus-server.c', line 66

static VALUE
cDBusServer_disconnect(VALUE self)
{
  dbus_server_disconnect(SERVER_GET(self));
  return Qnil;
}

#get_addressObject

Returns the address the server is listening on.



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'ext/ruby-dbus-server.c', line 93

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;
}

#get_is_connectedObject

Returns true if the server is still listening for new clients.



79
80
81
82
83
84
85
# File 'ext/ruby-dbus-server.c', line 79

static VALUE
cDBusServer_get_is_connected(VALUE self)
{
  if (dbus_server_get_is_connected(SERVER_GET(self)))
    return Qtrue;
  return Qfalse;
}

#setup_with_g_mainnil

Sets up the dispatching of the server to integrate with the GLIB main loop.

Returns:

  • (nil)


114
115
116
117
118
119
# File 'ext/ruby-dbus-server.c', line 114

static VALUE
cDBusServer_setup_with_g_main(VALUE self)
{
  dbus_server_setup_with_g_main(SERVER_GET(self), NULL);
  return Qnil;
}