freeswitcher 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fsr/listener/inbound.rb +1 -1
- data/lib/fsr/version.rb +1 -1
- data/spec/fsr/listener/inbound.rb +12 -0
- metadata +1 -1
data/lib/fsr/listener/inbound.rb
CHANGED
@@ -105,7 +105,7 @@ module FSR
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def subscribe_to_event(event, sub_events = [])
|
108
|
-
sub_events = [sub_events] unless sub_events.
|
108
|
+
sub_events = [sub_events] unless sub_events.kind_of?(Array)
|
109
109
|
@subscribed_events << event
|
110
110
|
@subscribed_sub_events += sub_events
|
111
111
|
if custom = @subscribed_events.delete(:CUSTOM)
|
data/lib/fsr/version.rb
CHANGED
@@ -39,6 +39,11 @@ class InboundListener2 < InboundListener
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
class InboundListener3 < InboundListener2
|
43
|
+
def before_session
|
44
|
+
add_event(:CUSTOM, "fifo::info") { |e| @custom_event = e }
|
45
|
+
end
|
46
|
+
end
|
42
47
|
describe "Testing FSR::Listener::Inbound" do
|
43
48
|
it "defines #post_init" do
|
44
49
|
FSR::Listener::Inbound.method_defined?(:post_init).should == true
|
@@ -72,6 +77,13 @@ EM.describe InboundListener do
|
|
72
77
|
done
|
73
78
|
end
|
74
79
|
|
80
|
+
should "be able to add custom event hooks with sub events" do
|
81
|
+
listener = InboundListener3.new(1234, {:auth => 'SecretPassword'})
|
82
|
+
@listener.receive_data("Content-Length: 22\n\nEvent-Name: CUSTOM\n\n")
|
83
|
+
@listener.custom_event.should.equal @listener.recvd_event.first
|
84
|
+
done
|
85
|
+
end
|
86
|
+
|
75
87
|
should "be able to add custom event hooks on classes, before instantiation" do
|
76
88
|
FSL::Inbound.add_event_hook(:HANGUP_EVENT) { |instance, event| instance.test_event = event }
|
77
89
|
listener = InboundListener2.new(1234, {:auth => 'SecretPassword'})
|