Class: DNSSD::Service
- Inherits:
-
Object
- Object
- DNSSD::Service
- Defined in:
- ext/rdnssd_service.c
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Access the services underlying thread.
Class Method Summary collapse
-
.DNSSD::Service.fullname(name, type, domain) ⇒ String
Concatenate a three-part domain name (as seen in DNSSD::Reply#fullname()) into a properly-escaped full domain name.
-
.DNSSD::Service.new ⇒ raises a RuntimeError
Services can only be instantiated using DNSSD.enumerate_domains(), DNSSD.browse(), DNSSD.register(), and DNSSD.resolve().
-
.split(fullname) ⇒ Object
Split a properly escaped multi-part domain name (as seen in DNSSD::Reply#fullname()) into an array of names.
-
.split_fullname(fullname) ⇒ Object
Split a properly escaped multi-part domain name (as seen in DNSSD::Reply#fullname()) into an array of names.
Instance Method Summary collapse
- #inspect ⇒ String
-
#stop ⇒ Object
Stops service closing the underlying socket and killing the underlying thread.
-
#stopped? ⇒ Boolean
Returns
true
if service has been stopped,false
otherwise.
Instance Attribute Details
#thread ⇒ Object (readonly)
Access the services underlying thread. Returns nil if the service is synchronous.
Class Method Details
.DNSSD::Service.fullname(name, type, domain) ⇒ String
Concatenate a three-part domain name (as seen in DNSSD::Reply#fullname()) into a properly-escaped full domain name.
Any dots or slashes in the name must NOT be escaped. May be nil
(to construct a PTR record name, e.g. “_ftp._tcp.apple.com”).
The type is the service type followed by the protocol, separated by a dot (e.g. “_ftp._tcp”).
The domain is the domain name, e.g. “apple.com”. Any literal dots or backslashes must be escaped.
Raises a ArgumentError
if the full service name cannot be constructed from the arguments.
77 78 79 80 81 82 |
# File 'ext/rdnssd_service.c', line 77
static VALUE
dnssd_service_s_fullname(VALUE klass, VALUE name, VALUE type, VALUE domain)
{
return dnssd_create_fullname( StringValueCStr(name), StringValueCStr(type),
StringValueCStr(domain), 1 );
}
|
.DNSSD::Service.new ⇒ raises a RuntimeError
Services can only be instantiated using DNSSD.enumerate_domains(), DNSSD.browse(), DNSSD.register(), and DNSSD.resolve().
107 108 109 110 111 112 |
# File 'ext/rdnssd_service.c', line 107
static VALUE
dnssd_service_new(int argc, VALUE *argv, VALUE klass)
{
dnssd_instantiation_error(rb_class2name(klass));
return Qnil;
}
|
.DNSSD::Service.split(fullname) ⇒ Array .DNSSD::Service.split_fullname(fullname) ⇒ Array
94 95 96 97 98 |
# File 'ext/rdnssd_service.c', line 94
static VALUE
dnssd_service_s_split(VALUE klass, VALUE fullname)
{
return dnssd_split_fullname(fullname);
}
|
.DNSSD::Service.split(fullname) ⇒ Array .DNSSD::Service.split_fullname(fullname) ⇒ Array
94 95 96 97 98 |
# File 'ext/rdnssd_service.c', line 94
static VALUE
dnssd_service_s_split(VALUE klass, VALUE fullname)
{
return dnssd_split_fullname(fullname);
}
|
Instance Method Details
#inspect ⇒ String
259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'ext/rdnssd_service.c', line 259
static VALUE
dnssd_service_inspect(VALUE self)
{
VALUE buf = rb_str_buf_new(32);
rb_str_buf_cat2(buf, "<#");
rb_str_buf_cat2(buf, rb_obj_classname(self));
if (dnssd_service_is_stopped(self)) {
rb_str_buf_cat2(buf, " (stopped)");
}
rb_str_buf_cat2(buf, ">");
return buf;
}
|
#stop ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'ext/rdnssd_service.c', line 171
static VALUE
dnssd_service_stop(VALUE service)
{
VALUE thread;
DNSServiceRef *client = (DNSServiceRef*)RDATA(service)->data;
/* set to null right away for a bit more thread safety */
RDATA(service)->data = NULL;
if (client == NULL) rb_raise(rb_eRuntimeError, "service is already stopped");
dnssd_service_free_client(client);
thread = rb_ivar_get(service, dnssd_iv_thread);
rb_ivar_set(service, dnssd_iv_block, Qnil);
rb_ivar_set(service, dnssd_iv_thread, Qnil);
if (!NIL_P(thread)) {
/* will raise error if thread is not a Ruby Thread */
rb_thread_kill(thread);
}
return service;
}
|
#stopped? ⇒ Boolean
Returns true
if service has been stopped, false
otherwise.
148 149 150 151 152 153 |
# File 'ext/rdnssd_service.c', line 148
static VALUE
dnssd_service_is_stopped(VALUE service)
{
DNSServiceRef *client = (DNSServiceRef*)RDATA(service)->data;
return client == NULL ? Qtrue : Qfalse;
}
|