Class: OtStatus::Query::Connection

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/otstatus.rb

Constant Summary collapse

QUERY =
[6.chr, 0.chr, 255.chr, 255.chr, 'info'].join

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query, connect_timeout, inactivity_timeout) ⇒ Connection

Returns a new instance of Connection.



36
37
38
39
40
# File 'lib/otstatus.rb', line 36

def initialize query, connect_timeout, inactivity_timeout
  @query = query
  self.pending_connect_timeout = connect_timeout
  self.comm_inactivity_timeout = inactivity_timeout
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



34
35
36
# File 'lib/otstatus.rb', line 34

def query
  @query
end

Instance Method Details

#post_initObject



42
43
44
45
# File 'lib/otstatus.rb', line 42

def post_init
  send_data QUERY
  @data = ""
end

#receive_data(data) ⇒ Object



47
48
49
50
# File 'lib/otstatus.rb', line 47

def receive_data data
  @data << data
  query.response = @data
end

#unbindObject



52
53
54
# File 'lib/otstatus.rb', line 52

def unbind
  EventMachine::stop_event_loop
end