freeswitcher 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,6 +21,15 @@ module FSR
21
21
  @output_format = args[:output_format] || "json"
22
22
  end
23
23
 
24
+ def connection_completed
25
+ authorize_and_register_for_events
26
+ end
27
+
28
+ def unbind
29
+ return unless @host && @port
30
+ EM.add_timer(1){ reconnect @host, @port }
31
+ end
32
+
24
33
  # post_init is called upon each "new" socket connection.
25
34
  #
26
35
  # If Freeswitcher hasn't started listening for inbound socket connections
@@ -30,10 +39,7 @@ module FSR
30
39
  def post_init
31
40
  if error?
32
41
  reconnect_until_succeeding
33
- else
34
- authorize_and_register_for_events
35
42
  end
36
- before_session
37
43
  end
38
44
 
39
45
  def reconnect_until_succeeding
@@ -1,18 +1,18 @@
1
- require_relative "../model"
1
+ require 'ostruct'
2
2
  module FSR
3
3
  module Model
4
- class Agent
5
- attr_reader :fields, :extension, :full_name
6
- include FSR::Model
7
-
8
- def initialize(headers, *data)
9
- @fields = headers
10
- @fields.each_with_index do |h,i|
11
- (class << self; self; end).send(:define_method,h.to_sym) { data[i] }
12
- end
4
+ class Agent < OpenStruct
5
+ attr_accessor :extension, :full_name
13
6
 
7
+ def initialize(fields, *data)
8
+ super(Hash[fields.zip(data)])
14
9
  @extension, @full_name = name.split("-", 2)
15
10
  end
11
+
12
+ def fields
13
+ raise NotImplementedError, "This class is now an OpenStruct"
14
+ end
15
+
16
16
  end
17
17
  end
18
18
  end
@@ -1,4 +1,5 @@
1
1
  require 'ostruct'
2
+
2
3
  module FSR
3
4
  module Model
4
5
  class Call < OpenStruct
@@ -9,6 +10,7 @@ module FSR
9
10
  def fields
10
11
  raise NotImplementedError, "This class is now an OpenStruct"
11
12
  end
13
+
12
14
  end
13
15
  end
14
16
  end
@@ -1,4 +1,5 @@
1
1
  require 'ostruct'
2
+
2
3
  module FSR
3
4
  module Model
4
5
  class Channel < OpenStruct
@@ -9,6 +10,7 @@ module FSR
9
10
  def fields
10
11
  raise NotImplementedError, "This class is now an OpenStruct"
11
12
  end
13
+
12
14
  end
13
15
  end
14
16
  end
@@ -1,15 +1,16 @@
1
- require_relative "../model"
1
+ require 'ostruct'
2
+
2
3
  module FSR
3
4
  module Model
4
- class Queue
5
- attr_reader :fields
6
- include FSR::Model
7
- def initialize(headers, *data)
8
- @fields = headers
9
- @fields.each_with_index do |h,i|
10
- (class << self; self; end).send(:define_method,h.to_sym) { data[i] }
11
- end
5
+ class Queue < OpenStruct
6
+ def initialize(fields, *data)
7
+ super(Hash[fields.zip(data)])
12
8
  end
9
+
10
+ def fields
11
+ raise NotImplementedError, "This class is now an OpenStruct"
12
+ end
13
+
13
14
  end
14
15
  end
15
16
  end
@@ -1,15 +1,17 @@
1
- require_relative "../model"
1
+ require 'ostruct'
2
+
2
3
  module FSR
3
4
  module Model
4
- class Tier
5
- attr_reader :fields
6
- include FSR::Model
7
- def initialize(headers, *data)
8
- @fields = headers
9
- @fields.each_with_index do |h,i|
10
- (class << self; self; end).send(:define_method,h.to_sym) { data[i] }
11
- end
5
+ class Tier < OpenStruct
6
+
7
+ def initialize(fields, *data)
8
+ super(Hash[fields.zip(data)])
12
9
  end
10
+
11
+ def fields
12
+ raise NotImplementedError, "This class is now an OpenStruct"
13
+ end
14
+
13
15
  end
14
16
  end
15
17
  end
data/lib/fsr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FSR
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -84,8 +84,7 @@ EM.describe InboundListener do
84
84
 
85
85
  should "be able to add custom event hooks with sub events" do
86
86
  listener = InboundListener3.new(1234, {:auth => 'SecretPassword'})
87
- @listener.receive_data("Content-Length: 18\nContent-Type: text/event-plain\n\nEvent-Name: CUSTOM\n\n")
88
- @listener.custom_event.should.not.be.nil
87
+ @listener.receive_data("Content-Length: 22\nContent-Type: text/event-plain\n\nEvent-Name: CUSTOM\n\n")
89
88
  @listener.custom_event.should.equal @listener.recvd_event.first
90
89
  done
91
90
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 4
9
- version: 0.5.4
8
+ - 5
9
+ version: 0.5.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jayson Vaughn
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-01-31 00:00:00 -06:00
20
+ date: 2011-02-16 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency