Class: Flic::Protocol::Connection
- Inherits:
-
Object
- Object
- Flic::Protocol::Connection
show all
- Defined in:
- lib/flic/protocol/connection.rb
Defined Under Namespace
Classes: ConnectionClosedError, NilResponse
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(socket) ⇒ Connection
Returns a new instance of Connection.
11
12
13
14
15
|
# File 'lib/flic/protocol/connection.rb', line 11
def initialize(socket)
@socket = socket
@read_semaphore = Mutex.new
@write_semaphore = Mutex.new
end
|
Instance Attribute Details
#socket ⇒ Object
Returns the value of attribute socket.
9
10
11
|
# File 'lib/flic/protocol/connection.rb', line 9
def socket
@socket
end
|
Instance Method Details
#close ⇒ Object
37
38
39
|
# File 'lib/flic/protocol/connection.rb', line 37
def close
@socket.close
end
|
#closed? ⇒ Boolean
33
34
35
|
# File 'lib/flic/protocol/connection.rb', line 33
def closed?
@socket.closed?
end
|
#recv_command ⇒ Object
21
22
23
|
# File 'lib/flic/protocol/connection.rb', line 21
def recv_command
Protocol.parse_event(recv_command)
end
|
#recv_event ⇒ Object
29
30
31
|
# File 'lib/flic/protocol/connection.rb', line 29
def recv_event
Protocol.parse_event(recv_packet)
end
|
#send_command(command) ⇒ Object
17
18
19
|
# File 'lib/flic/protocol/connection.rb', line 17
def send_command(command)
send_packet Protocol.serialize_command(command)
end
|
#send_event(event) ⇒ Object
25
26
27
|
# File 'lib/flic/protocol/connection.rb', line 25
def send_event(event)
send_packet Protocol.serialize_event(event)
end
|