diff options
author | spag <spag@golwen.net> | 2013-02-11 10:06:41 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-02-11 10:06:41 +0100 |
commit | a389e71521f526d918001a00878f363314fa7027 (patch) | |
tree | b7374205b82d86fbfd577e47f5e0b26670024766 /lib/freeswitch_event.rb | |
parent | af16d6106e5b4c81a8b167397c0fffd728762fa0 (diff) |
channel_variable_get method added
Diffstat (limited to 'lib/freeswitch_event.rb')
-rw-r--r-- | lib/freeswitch_event.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/freeswitch_event.rb b/lib/freeswitch_event.rb index b6e5cbc..68d9df2 100644 --- a/lib/freeswitch_event.rb +++ b/lib/freeswitch_event.rb @@ -44,8 +44,8 @@ class FreeswitchEventSocket @socket.close end - def read() - return @socket.recv(1024) + def read(read_bytes=1024) + return @socket.recv(read_bytes) end def result() @@ -130,4 +130,20 @@ class FreeswitchAPI return false end + + def self.channel_variable_get(channel_uuid, variable_name) + result = nil + event = FreeswitchEventSocket.new() + if event && event.connect() + event.command( "api uuid_getvar #{channel_uuid} #{variable_name}") + event_result = event.result() + if event_result && event_result["Content-Type"] == 'api/response' && event_result["Content-Length"].to_i > 0 + result = event.read(event_result["Content-Length"].to_i) + end + event.close() + end + + return result + end + end |