From a26715b9329e403c4253eddf033769db27bba775 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 18 Oct 2020 15:39:23 -0500 Subject: [PATCH] admin build --- admin/app/admin/ars.rb | 25 ++++++++++++++++ admin/config/initializers/jam_ruby_ars.rb | 3 +- pb/src/client_container.proto | 6 ++++ ruby/lib/jam_ruby/message_factory.rb | 29 ++++++++++--------- .../lib/jam_websockets/router.rb | 18 ++++++++++-- 5 files changed, 64 insertions(+), 17 deletions(-) diff --git a/admin/app/admin/ars.rb b/admin/app/admin/ars.rb index e150e4401..0b8c4def0 100644 --- a/admin/app/admin/ars.rb +++ b/admin/app/admin/ars.rb @@ -2,4 +2,29 @@ ActiveAdmin.register JamRuby::Ars, :as => 'Ars' do menu :label => 'NAS', :parent => 'Operations' + + form do |f| + f.inputs 'Controls' do + f.input :active + f.input :beta + end + f.inputs 'Meta' do + f.input :name + f.input :provider + f.input :id_int + f.input :ip + f.input :username + f.input :password, as: :string + f.input :port + f.input :continent + f.input :country, as: :string + f.input :city + f.input :subdivision + f.input :latitude + f.input :longitude + end + f.actions + end + + end diff --git a/admin/config/initializers/jam_ruby_ars.rb b/admin/config/initializers/jam_ruby_ars.rb index 5b879aa4e..2fe51d24c 100644 --- a/admin/config/initializers/jam_ruby_ars.rb +++ b/admin/config/initializers/jam_ruby_ars.rb @@ -1,6 +1,5 @@ class JamRuby::Ars - attr_accessible :password - + attr_accessible :password, :username, :active, :beta, :name, :provider, :id_int, :ip, :port, :continent, :country, :city, :subdivision, :latitude, :longitude, as: :admin end diff --git a/pb/src/client_container.proto b/pb/src/client_container.proto index db747dac8..0eb19091a 100644 --- a/pb/src/client_container.proto +++ b/pb/src/client_container.proto @@ -816,6 +816,12 @@ message Ars { optional string username = 4; optional string password = 5; optional int32 port = 6; + optional string country = 7; + optional string continent = 8; + optional string subdivision = 9; + optional double latitude = 10; + optional double longitude = 11; + optional string city = 12; } // target: client diff --git a/ruby/lib/jam_ruby/message_factory.rb b/ruby/lib/jam_ruby/message_factory.rb index 687a0fba1..f4d9844ec 100644 --- a/ruby/lib/jam_ruby/message_factory.rb +++ b/ruby/lib/jam_ruby/message_factory.rb @@ -68,8 +68,23 @@ module JamRuby ) end + def ars_body(ars) + Jampb::Ars.new( + :id => ars.id_int, + :ip => ars.ip, + :username => ars.username, + :password => ars.password, + :port => ars.port, + :country => ars.country, + :continent => ars.continent, + :city => ars.city, + :subdivision => ars.subdivision, + :latitude => ars.latitude, + :longitude => ars.longitude + ) + end # create a login ack (login was successful) - def login_ack(public_ip, client_id, token, heartbeat_interval, music_session_id, reconnected, user_id, connection_expire_time, username, client_id_int, client_update_data = nil, ars_list = nil) + def login_ack(public_ip, client_id, token, heartbeat_interval, music_session_id, reconnected, user_id, connection_expire_time, username, client_id_int, client_update_data = nil, arses = []) client_update = Jampb::ClientUpdate.new( product: client_update_data[:product], version: client_update_data[:version], @@ -77,18 +92,6 @@ module JamRuby size: client_update_data[:size] ) if client_update_data - arses = [] - - ars_list.each do |ars| - arses << Jampb::Ars.new( - :id => ars.id_int, - :ip => ars.ip, - :username => ars.username, - :password => ars.password, - :port => ars.port - ) - end if ars_list - login_ack = Jampb::LoginAck.new( :public_ip => public_ip, diff --git a/websocket-gateway/lib/jam_websockets/router.rb b/websocket-gateway/lib/jam_websockets/router.rb index 02cd31594..aaad62903 100644 --- a/websocket-gateway/lib/jam_websockets/router.rb +++ b/websocket-gateway/lib/jam_websockets/router.rb @@ -1362,8 +1362,22 @@ module JamWebsockets # it's possible that a client will not be represented in the database anymore, due to hard to trace/guess scenario # usually involve reconnects. Double-check that all clients in memory are actually in the database. if not, delete them from memory - @stored_ars = Ars.active_arses(true) - @stored_ars_beta = Ars.active_arses(false) + stored_ars_raw = Ars.active_arses(true) + stored_ars_beta_raw = Ars.active_arses(false) + + stored_ars = [] + stored_ars_beta = [] + stored_ars_raw.each do |ars| + stored_ars << @message_factory.ars_body(ars) + end + stored_ars_beta_raw.each do |ars| + stored_ars_beta << @message_factory.ars_body(ars) + end + @stored_ars = stored_ars + @stored_ars_beta = stored_ars_beta + + puts "STORADE ARS #{@stored_ars}" + puts "STORADE ARS BETA #{@stored_ars_beta}" if @client_lookup.length == 0 return