diff --git a/README.md b/README.md index 3427661..e2326ce 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,10 @@ port is quite simple: it takes an optional hash with arguments: Librevox.start SomeListener, :host => "1.2.3.4", :port => "8087", :auth => "pwd" + +filters can be applied to a listerner with the filters argument + + Librevox.start SomeListener, :filters => ["Event-Name CHANNEL_EXECUTE", "Event-NAME HEARTBEAT"] Multiple listeners can be started at once by passing a block to `Librevox.start`: @@ -129,6 +133,7 @@ Multiple listeners can be started at once by passing a block to `Librevox.start` run SomeListener run OtherListener, :port => "8080" end + ## Closing connection diff --git a/TODO b/TODO index c18d42f..3e09ef6 100644 --- a/TODO +++ b/TODO @@ -5,8 +5,6 @@ - check command/application input and raise ArgumentError, possibly. -- filter events - - move test suite from bacon -> test/unit. - test how this works in async mode - I imagine that it might mess with diff --git a/lib/librevox/listener/inbound.rb b/lib/librevox/listener/inbound.rb index 96165ae..d7ed772 100644 --- a/lib/librevox/listener/inbound.rb +++ b/lib/librevox/listener/inbound.rb @@ -8,7 +8,8 @@ def initialize args={} @auth = args[:auth] || "ClueCon" @host, @port = args.values_at(:host, :port) - + @filters = args[:filters] || [] + EventMachine.add_shutdown_hook {@shutdown = true} end @@ -17,6 +18,7 @@ def connection_completed super send_data "auth #{@auth}\n\n" send_data "event plain ALL\n\n" + @filters.each { |f| send_data "filter #{f}\n\n" } end def unbind