Class: Librevox::CommandSocket
- Inherits:
-
Object
- Object
- Librevox::CommandSocket
show all
- Includes:
- Commands
- Defined in:
- lib/librevox/command_socket.rb
Instance Method Summary
collapse
Methods included from Commands
#fsctl, #hash, #hupall, #originate, #status, #uuid_bridge, #uuid_park
Constructor Details
Returns a new instance of CommandSocket.
10
11
12
13
14
15
16
|
# File 'lib/librevox/command_socket.rb', line 10
def initialize args={}
@server = args[:server] || "127.0.0.1"
@port = args[:port] || "8021"
@auth = args[:auth] || "ClueCon"
connect unless args[:connect] == false
end
|
Instance Method Details
#close ⇒ Object
51
52
53
|
# File 'lib/librevox/command_socket.rb', line 51
def close
@socket.close
end
|
#command(*args) ⇒ Object
24
25
26
27
|
# File 'lib/librevox/command_socket.rb', line 24
def command *args
@socket.print "#{super(*args)}\n\n"
read_response
end
|
#connect ⇒ Object
18
19
20
21
22
|
# File 'lib/librevox/command_socket.rb', line 18
def connect
@socket = TCPSocket.open(@server, @port)
@socket.print "auth #{@auth}\n\n"
read_response
end
|
41
42
43
44
45
46
47
48
49
|
# File 'lib/librevox/command_socket.rb', line 41
def
= ""
while line = @socket.gets and !line.chomp.empty?
+= line
end
end
|
#read_response ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/librevox/command_socket.rb', line 29
def read_response
response = Librevox::Response.new
until response.command_reply? or response.api_response?
response. =
end
length = response.[:content_length].to_i
response.content = @socket.read(length) if length > 0
response
end
|