* VRFS-1372 resolved, and not requiring local only until figure out some deployment issues
This commit is contained in:
parent
adb37e06a6
commit
faed48271b
|
|
@ -222,7 +222,7 @@ ActiveAdmin.register_page "Bootstrap" do
|
||||||
elsif IcecastMountTemplate.count == 0
|
elsif IcecastMountTemplate.count == 0
|
||||||
semantic_form_for IcecastMountTemplate.new, :url => admin_bootstrap_create_mount_template_path, :builder => ActiveAdmin::FormBuilder do |f|
|
semantic_form_for IcecastMountTemplate.new, :url => admin_bootstrap_create_mount_template_path, :builder => ActiveAdmin::FormBuilder do |f|
|
||||||
f.inputs "New Mount Template" do
|
f.inputs "New Mount Template" do
|
||||||
f.input :hostname, :label => "UNUSED?? jam-web public hostname:port (such that icecast can reach it)"
|
f.input :hostname, :label => "jam-web public hostname:port (such that icecast can reach it)"
|
||||||
f.input :default_mime_type, :as => :select, :collection => ["ogg", "mp3"]
|
f.input :default_mime_type, :as => :select, :collection => ["ogg", "mp3"]
|
||||||
end
|
end
|
||||||
f.actions
|
f.actions
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,4 @@ scores_mod_users2.sql
|
||||||
user_bio.sql
|
user_bio.sql
|
||||||
track_changes_counter.sql
|
track_changes_counter.sql
|
||||||
scores_better_test_data.sql
|
scores_better_test_data.sql
|
||||||
|
connection_client_type.sql
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE connections ADD COLUMN client_type VARCHAR(256) NOT NULL;
|
||||||
|
|
@ -164,7 +164,7 @@ message Login {
|
||||||
optional string token = 3; // a token/cookie from previous successful login attempt or from 'token' field in .music file
|
optional string token = 3; // a token/cookie from previous successful login attempt or from 'token' field in .music file
|
||||||
optional string client_id = 4; // if supplied, the server will accept this client_id as the unique Id of this client instance
|
optional string client_id = 4; // if supplied, the server will accept this client_id as the unique Id of this client instance
|
||||||
optional string reconnect_music_session_id = 5; // if supplied, the server will attempt to log the client into this session (designed for reconnect scenarios while in-session)
|
optional string reconnect_music_session_id = 5; // if supplied, the server will attempt to log the client into this session (designed for reconnect scenarios while in-session)
|
||||||
|
optional string client_type = 6; // 'client', 'browser'
|
||||||
}
|
}
|
||||||
|
|
||||||
// route_to: client
|
// route_to: client
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,11 @@ SQL
|
||||||
# this number is used by notification logic elsewhere to know
|
# this number is used by notification logic elsewhere to know
|
||||||
# 'oh the user joined for the 1st time, so send a friend update', or
|
# 'oh the user joined for the 1st time, so send a friend update', or
|
||||||
# 'don't bother because the user has connected somewhere else already'
|
# 'don't bother because the user has connected somewhere else already'
|
||||||
def create_connection(user_id, client_id, ip_address, &blk)
|
def create_connection(user_id, client_id, ip_address, client_type, &blk)
|
||||||
|
|
||||||
|
# validate client_type
|
||||||
|
raise "invalid client_type: #{client_type}" if client_type != 'client' && client_type != 'browser'
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
ConnectionManager.active_record_transaction do |connection_manager|
|
ConnectionManager.active_record_transaction do |connection_manager|
|
||||||
conn = connection_manager.pg_conn
|
conn = connection_manager.pg_conn
|
||||||
|
|
@ -242,8 +246,8 @@ SQL
|
||||||
|
|
||||||
lock_connections(conn)
|
lock_connections(conn)
|
||||||
|
|
||||||
conn.exec("INSERT INTO connections (user_id, client_id, ip_address, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
conn.exec("INSERT INTO connections (user_id, client_id, ip_address, client_type, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||||
[user_id, client_id, ip_address, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s]).clear
|
[user_id, client_id, ip_address, client_type, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s]).clear
|
||||||
|
|
||||||
# we just created a new connection-if this is the first time the user has shown up, we need to send out a message to his friends
|
# we just created a new connection-if this is the first time the user has shown up, we need to send out a message to his friends
|
||||||
conn.exec("SELECT count(user_id) FROM connections WHERE user_id = $1", [user_id]) do |result|
|
conn.exec("SELECT count(user_id) FROM connections WHERE user_id = $1", [user_id]) do |result|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ module JamRuby
|
||||||
|
|
||||||
|
|
||||||
validates :as_musician, :inclusion => {:in => [true, false]}
|
validates :as_musician, :inclusion => {:in => [true, false]}
|
||||||
|
validates :client_type, :inclusion => {:in => ['client', 'browser']}
|
||||||
validate :can_join_music_session, :if => :joining_session?
|
validate :can_join_music_session, :if => :joining_session?
|
||||||
after_save :require_at_least_one_track_when_in_session, :if => :joining_session?
|
after_save :require_at_least_one_track_when_in_session, :if => :joining_session?
|
||||||
after_create :did_create
|
after_create :did_create
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ FactoryGirl.define do
|
||||||
countrycode 'US'
|
countrycode 'US'
|
||||||
region 'TX'
|
region 'TX'
|
||||||
city 'Austin'
|
city 'Austin'
|
||||||
|
client_type 'client'
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :invitation, :class => JamRuby::Invitation do
|
factory :invitation, :class => JamRuby::Invitation do
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ describe ConnectionManager do
|
||||||
user.save!
|
user.save!
|
||||||
user = nil
|
user = nil
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
expect { @connman.create_connection(user_id, client_id, "1.1.1.1") }.to raise_error(PG::Error)
|
expect { @connman.create_connection(user_id, client_id, "1.1.1.1", 'client') }.to raise_error(PG::Error)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "create connection then delete it" do
|
it "create connection then delete it" do
|
||||||
|
|
@ -63,7 +63,7 @@ describe ConnectionManager do
|
||||||
#user_id = create_user("test", "user2", "user2@jamkazam.com")
|
#user_id = create_user("test", "user2", "user2@jamkazam.com")
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
count = @connman.create_connection(user.id, client_id, "1.1.1.1")
|
count = @connman.create_connection(user.id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
count.should == 1
|
count.should == 1
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ describe ConnectionManager do
|
||||||
#user_id = create_user("test", "user2", "user2@jamkazam.com")
|
#user_id = create_user("test", "user2", "user2@jamkazam.com")
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
count = @connman.create_connection(user.id, client_id, "1.1.1.1")
|
count = @connman.create_connection(user.id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
count.should == 1
|
count.should == 1
|
||||||
|
|
||||||
|
|
@ -151,12 +151,12 @@ describe ConnectionManager do
|
||||||
# friend_update = @message_factory.friend_update(user_id, true)
|
# friend_update = @message_factory.friend_update(user_id, true)
|
||||||
# @connman.mq_router.should_receive(:publish_to_friends).with([], friend_update, user_id)
|
# @connman.mq_router.should_receive(:publish_to_friends).with([], friend_update, user_id)
|
||||||
|
|
||||||
# @connman.create_connection(user_id, client_id, "1.1.1.1")
|
# @connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
# # but a second connection from the same user should cause no such message
|
# # but a second connection from the same user should cause no such message
|
||||||
# @connman.should_receive(:publish_to_friends).exactly(0).times
|
# @connman.should_receive(:publish_to_friends).exactly(0).times
|
||||||
|
|
||||||
# @connman.create_connection(user_id, client_id2, "1.1.1.1")
|
# @connman.create_connection(user_id, client_id2, "1.1.1.1", 'client')
|
||||||
|
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
@ -170,8 +170,8 @@ describe ConnectionManager do
|
||||||
|
|
||||||
# # we should get a message saying that this user is online
|
# # we should get a message saying that this user is online
|
||||||
|
|
||||||
# @connman.create_connection(user_id, client_id, "1.1.1.1")
|
# @connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
# @connman.create_connection(user_id, client_id2, "1.1.1.1")
|
# @connman.create_connection(user_id, client_id2, "1.1.1.1", 'client')
|
||||||
|
|
||||||
# # deleting one of the two connections should cause no messages
|
# # deleting one of the two connections should cause no messages
|
||||||
# @connman.should_receive(:publish_to_friends).exactly(0).times
|
# @connman.should_receive(:publish_to_friends).exactly(0).times
|
||||||
|
|
@ -237,7 +237,7 @@ describe ConnectionManager do
|
||||||
it "flag stale connection" do
|
it "flag stale connection" do
|
||||||
client_id = "client_id8"
|
client_id = "client_id8"
|
||||||
user_id = create_user("test", "user8", "user8@jamkazam.com")
|
user_id = create_user("test", "user8", "user8@jamkazam.com")
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
num = JamRuby::Connection.count(:conditions => ['aasm_state = ?','connected'])
|
num = JamRuby::Connection.count(:conditions => ['aasm_state = ?','connected'])
|
||||||
num.should == 1
|
num.should == 1
|
||||||
|
|
@ -271,11 +271,11 @@ describe ConnectionManager do
|
||||||
it "expires stale connection" do
|
it "expires stale connection" do
|
||||||
client_id = "client_id8"
|
client_id = "client_id8"
|
||||||
user_id = create_user("test", "user8", "user8@jamkazam.com")
|
user_id = create_user("test", "user8", "user8@jamkazam.com")
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
@connman.flag_stale_connections(1)
|
@connman.flag_stale_connections(1)
|
||||||
assert_num_connections(client_id, 1)
|
assert_num_connections(client_id, 1)
|
||||||
# assert_num_connections(client_id, JamRuby::Connection.count(:conditions => ['aasm_state = ?','stale']))
|
# assert_num_connections(client_id, JamRuby::Connection.count(:conditions => ['aasm_state = ?','stale']))
|
||||||
|
|
||||||
@connman.expire_stale_connections(60)
|
@connman.expire_stale_connections(60)
|
||||||
|
|
@ -296,11 +296,11 @@ describe ConnectionManager do
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
music_session = MusicSession.find(music_session_id)
|
music_session = MusicSession.find(music_session_id)
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
|
|
||||||
connection.errors.any?.should be_false
|
connection.errors.any?.should be_false
|
||||||
|
|
||||||
assert_session_exists(music_session_id, true)
|
assert_session_exists(music_session_id, true)
|
||||||
|
|
||||||
@conn.exec("SELECT music_session_id FROM connections WHERE client_id = $1", [client_id]) do |result|
|
@conn.exec("SELECT music_session_id FROM connections WHERE client_id = $1", [client_id]) do |result|
|
||||||
|
|
@ -332,8 +332,8 @@ describe ConnectionManager do
|
||||||
client_id2 = "client_id10.12"
|
client_id2 = "client_id10.12"
|
||||||
user_id = create_user("test", "user10.11", "user10.11@jamkazam.com", :musician => true)
|
user_id = create_user("test", "user10.11", "user10.11@jamkazam.com", :musician => true)
|
||||||
user_id2 = create_user("test", "user10.12", "user10.12@jamkazam.com", :musician => false)
|
user_id2 = create_user("test", "user10.12", "user10.12@jamkazam.com", :musician => false)
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
@connman.create_connection(user_id2, client_id2, "1.1.1.1")
|
@connman.create_connection(user_id2, client_id2, "1.1.1.1", 'client')
|
||||||
|
|
||||||
music_session_id = create_music_session(user_id)
|
music_session_id = create_music_session(user_id)
|
||||||
|
|
||||||
|
|
@ -352,7 +352,7 @@ describe ConnectionManager do
|
||||||
it "as_musician is coerced to boolean" do
|
it "as_musician is coerced to boolean" do
|
||||||
client_id = "client_id10.2"
|
client_id = "client_id10.2"
|
||||||
user_id = create_user("test", "user10.2", "user10.2@jamkazam.com", :musician => false)
|
user_id = create_user("test", "user10.2", "user10.2@jamkazam.com", :musician => false)
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
music_session_id = create_music_session(user_id)
|
music_session_id = create_music_session(user_id)
|
||||||
|
|
||||||
|
|
@ -370,8 +370,8 @@ describe ConnectionManager do
|
||||||
fan_client_id = "client_id10.4"
|
fan_client_id = "client_id10.4"
|
||||||
musician_id = create_user("test", "user10.3", "user10.3@jamkazam.com")
|
musician_id = create_user("test", "user10.3", "user10.3@jamkazam.com")
|
||||||
fan_id = create_user("test", "user10.4", "user10.4@jamkazam.com", :musician => false)
|
fan_id = create_user("test", "user10.4", "user10.4@jamkazam.com", :musician => false)
|
||||||
@connman.create_connection(musician_id, musician_client_id, "1.1.1.1")
|
@connman.create_connection(musician_id, musician_client_id, "1.1.1.1", 'client')
|
||||||
@connman.create_connection(fan_id, fan_client_id, "1.1.1.1")
|
@connman.create_connection(fan_id, fan_client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
music_session_id = create_music_session(musician_id, :fan_access => false)
|
music_session_id = create_music_session(musician_id, :fan_access => false)
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ describe ConnectionManager do
|
||||||
# now join the session as a fan, bt fan_access = false
|
# now join the session as a fan, bt fan_access = false
|
||||||
user = User.find(fan_id)
|
user = User.find(fan_id)
|
||||||
connection = @connman.join_music_session(user, fan_client_id, music_session, false, TRACKS)
|
connection = @connman.join_music_session(user, fan_client_id, music_session, false, TRACKS)
|
||||||
connection.errors.size.should == 1
|
connection.errors.size.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "join_music_session fails if incorrect user_id specified" do
|
it "join_music_session fails if incorrect user_id specified" do
|
||||||
|
|
@ -396,7 +396,7 @@ describe ConnectionManager do
|
||||||
user = User.find(user_id2)
|
user = User.find(user_id2)
|
||||||
music_session = MusicSession.find(music_session_id)
|
music_session = MusicSession.find(music_session_id)
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
# specify real user id, but not associated with this session
|
# specify real user id, but not associated with this session
|
||||||
expect { @connman.join_music_session(user, client_id, music_session, true, TRACKS) } .to raise_error(ActiveRecord::RecordNotFound)
|
expect { @connman.join_music_session(user, client_id, music_session, true, TRACKS) } .to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
@ -408,7 +408,7 @@ describe ConnectionManager do
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
music_session = MusicSession.new
|
music_session = MusicSession.new
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
connection.errors.size.should == 1
|
connection.errors.size.should == 1
|
||||||
connection.errors.get(:music_session).should == [ValidationMessages::MUSIC_SESSION_MUST_BE_SPECIFIED]
|
connection.errors.get(:music_session).should == [ValidationMessages::MUSIC_SESSION_MUST_BE_SPECIFIED]
|
||||||
|
|
@ -423,7 +423,7 @@ describe ConnectionManager do
|
||||||
user = User.find(user_id2)
|
user = User.find(user_id2)
|
||||||
music_session = MusicSession.find(music_session_id)
|
music_session = MusicSession.find(music_session_id)
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
# specify real user id, but not associated with this session
|
# specify real user id, but not associated with this session
|
||||||
expect { @connman.join_music_session(user, client_id, music_session, true, TRACKS) } .to raise_error(ActiveRecord::RecordNotFound)
|
expect { @connman.join_music_session(user, client_id, music_session, true, TRACKS) } .to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
@ -437,7 +437,7 @@ describe ConnectionManager do
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
dummy_music_session = MusicSession.new
|
dummy_music_session = MusicSession.new
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
|
|
||||||
expect { @connman.leave_music_session(user, Connection.find_by_client_id(client_id), dummy_music_session) }.to raise_error(JamRuby::StateError)
|
expect { @connman.leave_music_session(user, Connection.find_by_client_id(client_id), dummy_music_session) }.to raise_error(JamRuby::StateError)
|
||||||
end
|
end
|
||||||
|
|
@ -453,7 +453,7 @@ describe ConnectionManager do
|
||||||
|
|
||||||
dummy_music_session = MusicSession.new
|
dummy_music_session = MusicSession.new
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
@connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
@connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
expect { @connman.leave_music_session(user, Connection.find_by_client_id(client_id), dummy_music_session) }.to raise_error(JamRuby::StateError)
|
expect { @connman.leave_music_session(user, Connection.find_by_client_id(client_id), dummy_music_session) }.to raise_error(JamRuby::StateError)
|
||||||
end
|
end
|
||||||
|
|
@ -467,7 +467,7 @@ describe ConnectionManager do
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
music_session = MusicSession.find(music_session_id)
|
music_session = MusicSession.find(music_session_id)
|
||||||
|
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
@connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
@connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
|
|
||||||
assert_session_exists(music_session_id, true)
|
assert_session_exists(music_session_id, true)
|
||||||
|
|
@ -497,11 +497,11 @@ describe ConnectionManager do
|
||||||
music_session = MusicSession.find(create_music_session(user_id))
|
music_session = MusicSession.find(create_music_session(user_id))
|
||||||
|
|
||||||
client_id = Faker::Number.number(20)
|
client_id = Faker::Number.number(20)
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
|
|
||||||
client_id = Faker::Number.number(20)
|
client_id = Faker::Number.number(20)
|
||||||
@connman.create_connection(user_id, client_id, Faker::Internet.ip_v4_address)
|
@connman.create_connection(user_id, client_id, Faker::Internet.ip_v4_address, 'client')
|
||||||
music_session = MusicSession.find(create_music_session(user_id))
|
music_session = MusicSession.find(create_music_session(user_id))
|
||||||
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
|
|
||||||
|
|
@ -510,11 +510,11 @@ describe ConnectionManager do
|
||||||
|
|
||||||
user.update_attribute(:admin, true)
|
user.update_attribute(:admin, true)
|
||||||
client_id = Faker::Number.number(20)
|
client_id = Faker::Number.number(20)
|
||||||
@connman.create_connection(user_id, client_id, "1.1.1.1")
|
@connman.create_connection(user_id, client_id, "1.1.1.1", 'client')
|
||||||
music_session = MusicSession.find(create_music_session(user_id))
|
music_session = MusicSession.find(create_music_session(user_id))
|
||||||
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
client_id = Faker::Number.number(20)
|
client_id = Faker::Number.number(20)
|
||||||
@connman.create_connection(user_id, client_id, Faker::Internet.ip_v4_address)
|
@connman.create_connection(user_id, client_id, Faker::Internet.ip_v4_address, 'client')
|
||||||
music_session = MusicSession.find(create_music_session(user_id))
|
music_session = MusicSession.find(create_music_session(user_id))
|
||||||
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS)
|
||||||
connection.errors.size.should == 0
|
connection.errors.size.should == 0
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,12 @@
|
||||||
// create a login message using token (a cookie or similiar)
|
// create a login message using token (a cookie or similiar)
|
||||||
// reconnect_music_session_id is an optional argument that allows the session to be immediately associated
|
// reconnect_music_session_id is an optional argument that allows the session to be immediately associated
|
||||||
// with a music session.
|
// with a music session.
|
||||||
factory.login_with_token = function(token, reconnect_music_session_id) {
|
factory.login_with_token = function(token, reconnect_music_session_id, client_type) {
|
||||||
//context.JK.logger.debug("*** login_with_token: client_id = "+$.cookie("client_id"));
|
//context.JK.logger.debug("*** login_with_token: client_id = "+$.cookie("client_id"));
|
||||||
var login = { token : token,
|
var login = {
|
||||||
client_id : $.cookie("client_id")
|
token : token,
|
||||||
|
client_id : $.cookie("client_id"),
|
||||||
|
client_type : client_type
|
||||||
};
|
};
|
||||||
return client_container(msg.LOGIN, route_to.SERVER, login);
|
return client_container(msg.LOGIN, route_to.SERVER, login);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@
|
||||||
server.rememberLogin = function() {
|
server.rememberLogin = function() {
|
||||||
var token, loginMessage;
|
var token, loginMessage;
|
||||||
token = $.cookie("remember_token");
|
token = $.cookie("remember_token");
|
||||||
loginMessage = msg_factory.login_with_token(token, null);
|
var clientType = context.jamClient.IsNativeClient() ? 'client' : 'browser';
|
||||||
|
loginMessage = msg_factory.login_with_token(token, null, clientType);
|
||||||
server.send(loginMessage);
|
server.send(loginMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -607,7 +607,7 @@
|
||||||
function CloseRecording() {}
|
function CloseRecording() {}
|
||||||
function OnDownloadAvailable() {}
|
function OnDownloadAvailable() {}
|
||||||
function SaveToClipboard(text) {}
|
function SaveToClipboard(text) {}
|
||||||
function IsNativeClient() { return false; }
|
function IsNativeClient() { /* must always return false in all scenarios due to not ruin scoring !*/ return false; }
|
||||||
|
|
||||||
function SessionLiveBroadcastStart(host, port, mount, sourceUser, sourcePass, preferredClientId, bitrate)
|
function SessionLiveBroadcastStart(host, port, mount, sourceUser, sourcePass, preferredClientId, bitrate)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var logger = context.JK.logger;
|
var logger = context.JK.logger;
|
||||||
|
var rest = context.JK.Rest();
|
||||||
var sessionLatency;
|
var sessionLatency;
|
||||||
var sessions = {};
|
var sessions = {};
|
||||||
var invitationSessionGroup = {};
|
var invitationSessionGroup = {};
|
||||||
|
|
@ -42,13 +43,19 @@
|
||||||
// squelch nulls and undefines
|
// squelch nulls and undefines
|
||||||
queryString = !!queryString ? queryString : "";
|
queryString = !!queryString ? queryString : "";
|
||||||
|
|
||||||
$.ajax({
|
if(gon.use_cached_session_scores) {
|
||||||
type: "GET",
|
rest.findScoredSessions(app.clientId, queryString)
|
||||||
url: "/api/sessions?" + queryString,
|
.done(afterLoadScoredSessions)
|
||||||
success: afterLoadSessions,
|
.always(removeSpinner)
|
||||||
complete: removeSpinner,
|
.fail(app.ajaxError)
|
||||||
error: app.ajaxError
|
}
|
||||||
});
|
else {
|
||||||
|
rest.findSessions(queryString)
|
||||||
|
.done(afterLoadSessions)
|
||||||
|
.fail(app.ajaxError)
|
||||||
|
.always(removeSpinner)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
|
|
@ -122,7 +129,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function afterLoadSessions(sessionList) {
|
function afterLoadScoredSessions(sessionList) {
|
||||||
|
|
||||||
|
// display the 'no sessions' banner if appropriate
|
||||||
|
var $noSessionsFound = $('#sessions-none-found');
|
||||||
|
if(sessionList.length == 0) {
|
||||||
|
$noSessionsFound.show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$noSessionsFound.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(sessionList, function(i, session) {
|
||||||
|
sessions[session.id] = session;
|
||||||
|
session.latencyInfo
|
||||||
|
});
|
||||||
|
|
||||||
|
$.each(sessionList, function(i, session) {
|
||||||
|
renderSession(session.id);
|
||||||
|
})
|
||||||
|
|
||||||
|
context.JK.GA.trackFindSessions(sessionList.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function afterLoadSessions(sessionList) {
|
||||||
|
|
||||||
// display the 'no sessions' banner if appropriate
|
// display the 'no sessions' banner if appropriate
|
||||||
var $noSessionsFound = $('#sessions-none-found');
|
var $noSessionsFound = $('#sessions-none-found');
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,20 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findSessions(queryString) {
|
||||||
|
return $.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/api/sessions?" + queryString
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function findScoredSessions(clientId, queryString) {
|
||||||
|
return $.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/api/sessions/nindex/" + clientId + "?" + queryString
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function updateSession(id, newSession) {
|
function updateSession(id, newSession) {
|
||||||
return $.ajax('/api/sessions/' + id, {
|
return $.ajax('/api/sessions/' + id, {
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
|
|
@ -897,6 +911,8 @@
|
||||||
this.getFollowers = getFollowers;
|
this.getFollowers = getFollowers;
|
||||||
this.getBands = getBands;
|
this.getBands = getBands;
|
||||||
this.getBandFollowers = getBandFollowers;
|
this.getBandFollowers = getBandFollowers;
|
||||||
|
this.findSessions = findSessions;
|
||||||
|
this.findScoredSessions = findScoredSessions;
|
||||||
this.updateSession = updateSession;
|
this.updateSession = updateSession;
|
||||||
this.getSessionHistory = getSessionHistory;
|
this.getSessionHistory = getSessionHistory;
|
||||||
this.addSessionComment = addSessionComment;
|
this.addSessionComment = addSessionComment;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,11 @@
|
||||||
var gearLatency = context.jamClient.SessionGetDeviceLatency();
|
var gearLatency = context.jamClient.SessionGetDeviceLatency();
|
||||||
var showJoinLink = true;
|
var showJoinLink = true;
|
||||||
|
|
||||||
|
// quick dance to make the new scoring find sessions API work
|
||||||
|
if(session.max_score) {
|
||||||
|
latencyInfo = {averageLatency: session.max_score}
|
||||||
|
}
|
||||||
|
|
||||||
var totalLatency = (latencyInfo.averageLatency / 2) + gearLatency;
|
var totalLatency = (latencyInfo.averageLatency / 2) + gearLatency;
|
||||||
|
|
||||||
logger.debug("latencyInfo.averageLatency=" + latencyInfo.averageLatency);
|
logger.debug("latencyInfo.averageLatency=" + latencyInfo.averageLatency);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class ApiIcecastController < ApiController
|
class ApiIcecastController < ApiController
|
||||||
before_filter :local_only
|
#before_filter :local_only
|
||||||
before_filter :parse_mount
|
before_filter :parse_mount
|
||||||
|
|
||||||
# each request will have this in it, if it's icecast.
|
# each request will have this in it, if it's icecast.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ class ClientsController < ApplicationController
|
||||||
# let javascript have access to the server's opinion if this is a native client
|
# let javascript have access to the server's opinion if this is a native client
|
||||||
gon.isNativeClient = @nativeClient
|
gon.isNativeClient = @nativeClient
|
||||||
|
|
||||||
|
gon.use_cached_session_scores = Rails.application.config.use_cached_session_scores
|
||||||
|
|
||||||
if current_user
|
if current_user
|
||||||
render :layout => 'client'
|
render :layout => 'client'
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -207,11 +207,6 @@
|
||||||
var ftueWizard = new JK.FtueWizard(JK.app);
|
var ftueWizard = new JK.FtueWizard(JK.app);
|
||||||
ftueWizard.initialize();
|
ftueWizard.initialize();
|
||||||
|
|
||||||
/* Commenting Out while reworking
|
|
||||||
var ftueAudioTestingScreen = new JK.FtueAudioTestingScreen(JK.app);
|
|
||||||
ftueAudioTestingScreen.initialize();
|
|
||||||
*/
|
|
||||||
|
|
||||||
var testBridgeScreen = new JK.TestBridgeScreen(JK.app);
|
var testBridgeScreen = new JK.TestBridgeScreen(JK.app);
|
||||||
testBridgeScreen.initialize();
|
testBridgeScreen.initialize();
|
||||||
|
|
||||||
|
|
@ -242,7 +237,7 @@
|
||||||
var start = new Date();
|
var start = new Date();
|
||||||
var returnVal = original.apply(originalJamClient, arguments)
|
var returnVal = original.apply(originalJamClient, arguments)
|
||||||
var time = new Date().getTime() - start.getTime();
|
var time = new Date().getTime() - start.getTime();
|
||||||
if(time > 0) {
|
if(time > 0) { // if 0, you'll see ALL bridge calls. If you set it to a higher value, you'll only see calls that are beyond that threshold
|
||||||
console.error(time + "ms jamClient." + jsKey);
|
console.error(time + "ms jamClient." + jsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,5 +214,8 @@ if defined?(Bundler)
|
||||||
config.send_join_session_email_notifications = true
|
config.send_join_session_email_notifications = true
|
||||||
|
|
||||||
config.use_promos_on_homepage = false
|
config.use_promos_on_homepage = false
|
||||||
|
|
||||||
|
# should we use the new FindSessions API that has server-side scores
|
||||||
|
config.use_cached_session_scores = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -67,5 +67,7 @@ SampleApp::Application.configure do
|
||||||
config.twitter_app_secret = 'PfG1jAUMnyrimPcDooUVQaJrG1IuDjUyGg5KciOo'
|
config.twitter_app_secret = 'PfG1jAUMnyrimPcDooUVQaJrG1IuDjUyGg5KciOo'
|
||||||
|
|
||||||
config.use_promos_on_homepage = false
|
config.use_promos_on_homepage = false
|
||||||
|
|
||||||
|
config.use_cached_session_scores = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ FactoryGirl.define do
|
||||||
countrycode 'US'
|
countrycode 'US'
|
||||||
region 'TX'
|
region 'TX'
|
||||||
city 'Austin'
|
city 'Austin'
|
||||||
|
client_type 'client'
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :friendship, :class => JamRuby::Friendship do
|
factory :friendship, :class => JamRuby::Friendship do
|
||||||
|
|
|
||||||
|
|
@ -448,8 +448,9 @@ module JamWebsockets
|
||||||
token = login.token if login.value_for_tag(3)
|
token = login.token if login.value_for_tag(3)
|
||||||
client_id = login.client_id if login.value_for_tag(4)
|
client_id = login.client_id if login.value_for_tag(4)
|
||||||
reconnect_music_session_id = login.reconnect_music_session_id if login.value_for_tag(5)
|
reconnect_music_session_id = login.reconnect_music_session_id if login.value_for_tag(5)
|
||||||
|
client_type = login.client_type if login.value_for_tag(6)
|
||||||
|
|
||||||
@log.info("*** handle_login: token=#{token}; client_id=#{client_id}")
|
@log.info("*** handle_login: token=#{token}; client_id=#{client_id}, client_type=#{client_type}")
|
||||||
reconnected = false
|
reconnected = false
|
||||||
|
|
||||||
# you don't have to supply client_id in login--if you don't, we'll generate one
|
# you don't have to supply client_id in login--if you don't, we'll generate one
|
||||||
|
|
@ -529,7 +530,7 @@ module JamWebsockets
|
||||||
unless connection
|
unless connection
|
||||||
# log this connection in the database
|
# log this connection in the database
|
||||||
ConnectionManager.active_record_transaction do |connection_manager|
|
ConnectionManager.active_record_transaction do |connection_manager|
|
||||||
connection_manager.create_connection(user.id, client.client_id, remote_ip) do |conn, count|
|
connection_manager.create_connection(user.id, client.client_id, remote_ip, client_type) do |conn, count|
|
||||||
if count == 1
|
if count == 1
|
||||||
Notification.send_friend_update(user.id, true, conn)
|
Notification.send_friend_update(user.id, true, conn)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue