diff --git a/web/app/assets/javascripts/JamServer.js b/web/app/assets/javascripts/JamServer.js index 139f86a89..e84b12929 100644 --- a/web/app/assets/javascripts/JamServer.js +++ b/web/app/assets/javascripts/JamServer.js @@ -657,6 +657,7 @@ client_type: isClientMode() ? context.JK.clientType() : 'latency_tester', client_id: isClientMode() ? (gon.global.env == "development" ? $.cookie('client_id') : null): context.jamClient.clientID, os: context.JK.GetOSAsString(), + jamblaster_serial_no: context.PlatformStore.jamblasterSerialNo(), udp_reachable: context.JK.StunInstance ? !context.JK.StunInstance.sync() : null // latency tester doesn't have the stun class loaded } diff --git a/web/app/assets/javascripts/react-components/stores/PlatformStore.js.coffee b/web/app/assets/javascripts/react-components/stores/PlatformStore.js.coffee index ded700fdd..a8a0ad556 100644 --- a/web/app/assets/javascripts/react-components/stores/PlatformStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/PlatformStore.js.coffee @@ -6,10 +6,23 @@ logger = context.JK.logger { logger: context.JK.logger os: null + serial_no: null init: -> this.listenTo(context.AppStore, this.onAppInit) + jamblasterSerialNo: () -> + + if @serial_no? + return @serial_no + + if context.jamClient.jamBlasterSerialNo + @serial_no = context.jamClient.jamBlasterSerialNo() + else + @serial_no= false + + @serial_no + onAppInit: (@app) -> @os = context.jamClient.GetOSAsString() this.trigger({os: @os, isWindows: @isWindows()}) diff --git a/websocket-gateway/lib/jam_websockets/router.rb b/websocket-gateway/lib/jam_websockets/router.rb index 9a301f37f..9feed29af 100644 --- a/websocket-gateway/lib/jam_websockets/router.rb +++ b/websocket-gateway/lib/jam_websockets/router.rb @@ -690,6 +690,7 @@ module JamWebsockets client_type = options["client_type"] os = options["os"] udp_reachable = options["udp_reachable"].nil? ? true : options["udp_reachable"] == 'true' + jamblaster_serial_no = options["jamblaster_serial_no"] client.subscriptions = Set.new# list of subscriptions that this client is watching in real-time @@ -708,6 +709,15 @@ module JamWebsockets client_id = UUIDTools::UUID.random_create.to_s end + # we have to deal with jamblaster before login + if jamblaster_serial_no + jamblaster = Jamblaster.find_by_serial_no(jamblaster_serial_no) + if jamblaster + jamblaster.client_id = client_id + jamblaster.save + end + end + user = valid_login(username, password, token, client_id) # protect against this user swamping the server