diff --git a/web/app/assets/javascripts/jquery.listenbroadcast.js b/web/app/assets/javascripts/jquery.listenbroadcast.js index 95c806af2..73837da8f 100644 --- a/web/app/assets/javascripts/jquery.listenbroadcast.js +++ b/web/app/assets/javascripts/jquery.listenbroadcast.js @@ -535,8 +535,10 @@ var $box = $(box) $mountState = $box.find('.listen-broadcast-state') - updateMountInfo(mountInfo) - updateMountDetails(mountInfo); + if(mountInfo) { + updateMountInfo(mountInfo) + updateMountDetails(mountInfo); + } } function updateMountInfo(mount) { diff --git a/websocket-gateway/bin/websocket_gateway b/websocket-gateway/bin/websocket_gateway index c3e09141d..456592701 100755 --- a/websocket-gateway/bin/websocket_gateway +++ b/websocket-gateway/bin/websocket_gateway @@ -72,5 +72,6 @@ Server.new.run(:port => config["port"] + (jam_instance-1 ) * 2, :influxdb_password => config['influxdb_password'], :influxdb_hosts => config['influxdb_hosts'], :influxdb_port => config['influxdb_port'], + :allow_dynamic_registration => config['allow_dynamic_registration'], :cidr => config['cidr'], :gateway_name => gateway_name) diff --git a/websocket-gateway/config/application.yml b/websocket-gateway/config/application.yml index 58b8bffd7..c01f4e5af 100644 --- a/websocket-gateway/config/application.yml +++ b/websocket-gateway/config/application.yml @@ -10,6 +10,7 @@ Defaults: &defaults influxdb_password: "root" influxdb_hosts: ["localhost"] influxdb_port: 8086 + allow_dynamic_registration: true development: port: 6767 diff --git a/websocket-gateway/lib/jam_websockets/router.rb b/websocket-gateway/lib/jam_websockets/router.rb index cf00b389b..fe2cb1bda 100644 --- a/websocket-gateway/lib/jam_websockets/router.rb +++ b/websocket-gateway/lib/jam_websockets/router.rb @@ -61,7 +61,7 @@ module JamWebsockets @disconnected_count = 0 end - def start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, options={:host => "localhost", :port => 5672, :max_connections_per_user => 10, :gateway => 'default'}, &block) + def start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, options={:host => "localhost", :port => 5672, :max_connections_per_user => 10, :gateway => 'default', :allow_dynamic_registration => true}, &block) @log.info "startup" @@ -73,6 +73,7 @@ module JamWebsockets @connect_time_expire_browser = connect_time_expire_browser @max_connections_per_user = options[:max_connections_per_user] @gateway_name = options[:gateway] + @allow_dynamic_registration = options[:allow_dynamic_registration] begin @amqp_connection_manager = AmqpConnectionManager.new(true, 4, :host => options[:host], :port => options[:port]) @@ -327,7 +328,9 @@ module JamWebsockets if clients.length == 0 # if there are no more clients listening, then unsubscribe to the topic for this mount_id - @subscription_topic.unbind(@subscriptions_exchange, :routing_key => "subscription.#{type}.#{id}") + routing_key = "subscription.#{type}.#{id}" + @log.debug("unregister dynamic topic #{routing_key}") + @subscription_topic.unbind(@subscriptions_exchange, :routing_key => routing_key) end end @@ -804,7 +807,7 @@ module JamWebsockets id = subscribe.id type = subscribe.type if id && id.length > 0 && type && type.length > 0 - #register_subscription(client, type, id) + register_subscription(client, type, id) if @allow_dynamic_registration else @log.error("handle_subscribe: empty data #{subscribe}") end @@ -814,7 +817,7 @@ module JamWebsockets id = unsubscribe.id type = unsubscribe.type if id && id.length > 0 && type && type.length > 0 - #unregister_subscription(client, type, id) + unregister_subscription(client, type, id) if @allow_dynamic_registration else @log.error("handle_subscribe: empty data #{unsubscribe}") end diff --git a/websocket-gateway/lib/jam_websockets/server.rb b/websocket-gateway/lib/jam_websockets/server.rb index d55d6fce5..fd45f7c42 100644 --- a/websocket-gateway/lib/jam_websockets/server.rb +++ b/websocket-gateway/lib/jam_websockets/server.rb @@ -24,6 +24,7 @@ module JamWebsockets gateway_name = options[:gateway_name] rabbitmq_host = options[:rabbitmq_host] rabbitmq_port = options[:rabbitmq_port].to_i + allow_dynamic_registration = options[:allow_dynamic_registration].nil? ? true : options[:allow_dynamic_registration] Stats::init(options) @@ -39,7 +40,7 @@ module JamWebsockets } EventMachine.run do - @router.start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, host: rabbitmq_host, port: rabbitmq_port, max_connections_per_user: max_connections_per_user, gateway: gateway_name) do + @router.start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, host: rabbitmq_host, port: rabbitmq_port, max_connections_per_user: max_connections_per_user, gateway: gateway_name, allow_dynamic_registration: allow_dynamic_registration) do start_connection_expiration start_client_expiration start_connection_flagger