Class: Idevice::HeartbeatClient
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from LibHelpers
included
#initialize
Class Method Details
.attach(opts = {}) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/idevice/heartbeat.rb', line 41
def self.attach(opts={})
_attach_helper("com.apple.mobile.heartbeat", opts) do |idevice, ldsvc, p_hb|
err=C.heartbeat_client_new(idevice, ldsvc, p_hb)
raise HeartbeatError, "Heartbeat error: #{err}" if err != :SUCCESS
hb = p_hb.read_pointer
raise HeartbeatError, "hearbeat_client_new returned a NULL client" if hb.null?
return new(hb)
end
end
|
.release(ptr) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/idevice/heartbeat.rb', line 33
def self.release(ptr)
C::Freelock.synchronize do
unless ptr.null?
C.heartbeat_client_free(ptr)
end
end
end
|
Instance Method Details
#receive_plist(timeout = nil) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/idevice/heartbeat.rb', line 57
def receive_plist(timeout=nil)
timeout ||= 1
FFI::MemoryPointer.new(:pointer) do |p_plist|
err = C.heartbeat_receive_with_timeout(self, p_plist, timeout)
raise HeartbeatError, "Heartbeat error: #{err}" if err != :SUCCESS
plist = p_plist.read_pointer
raise HeartbeatError, "hearbeat_receive returned a NULL plist" if plist.null?
return Plist.new(plist).to_ruby
end
end
|
#send_plist(obj) ⇒ Object
51
52
53
54
55
|
# File 'lib/idevice/heartbeat.rb', line 51
def send_plist(obj)
err = C.heartbeat_send(self, obj.to_plist_t)
raise HeartbeatError, "Heartbeat error: #{err}" if err != :SUCCESS
return true
end
|