removed updating with with connection location attributes

This commit is contained in:
Scott Comer 2014-03-04 18:48:29 -06:00
parent f0a0f9f2f2
commit 057a2b79dd
3 changed files with 7 additions and 100 deletions

View File

@ -44,7 +44,7 @@ module JamRuby
end
# reclaim the existing connection, if ip_address is not nil then perhaps a new address as well
def reconnect(conn, reconnect_music_session_id, ip_address, &blk)
def reconnect(conn, reconnect_music_session_id, ip_address)
music_session_id = nil
reconnected = false
@ -98,9 +98,6 @@ module JamRuby
conn.region = region
conn.city = city
conn.save!(validate: false)
# we're passing all this stuff so that the user record might be updated as well...
blk.call(addr, locidispid, latitude, longitude, countrycode, region, city) unless blk.nil?
end
sql =<<SQL
@ -252,7 +249,7 @@ SQL
conn.exec("SELECT count(user_id) FROM connections WHERE user_id = $1", [user_id]) do |result|
count = result.getvalue(0, 0) .to_i
# we're passing all this stuff so that the user record might be updated as well...
blk.call(conn, count, addr, locidispid, latitude, longitude, countrycode, region, city) unless blk.nil?
blk.call(conn, count) unless blk.nil?
end
return count
end

View File

@ -63,19 +63,7 @@ describe ConnectionManager do
#user_id = create_user("test", "user2", "user2@jamkazam.com")
user = FactoryGirl.create(:user)
count = @connman.create_connection(user.id, client_id, "1.1.1.1") { |conn, count, addr, locidispid, latitude, longitude, countrycode, region, city|
# first update the user record with the current location
u = User.find(user.id)
u.addr = addr
u.locidispid = locidispid
u.lat = latitude
u.lng = longitude
u.country = countrycode
u.state = region
u.city = city;
u.save!
u = nil
}
count = @connman.create_connection(user.id, client_id, "1.1.1.1")
count.should == 1
@ -96,17 +84,6 @@ describe ConnectionManager do
cc.region.should eql('TX')
cc.countrycode.should eql('US')
x = User.find(user.id)
#x.ip_address.should eql("1.1.1.1")
x.addr.should == 0x01010101
x.locidispid.should == 17192000002
x.lat.should == 30.2076
x.lng.should == -97.8587
x.city.should eql('Austin')
x.state.should eql('TX')
x.country.should eql('US')
x = nil
count = @connman.delete_connection(client_id)
count.should == 0
@ -121,19 +98,7 @@ describe ConnectionManager do
#user_id = create_user("test", "user2", "user2@jamkazam.com")
user = FactoryGirl.create(:user)
count = @connman.create_connection(user.id, client_id, "1.1.1.1") { |conn, count, addr, locidispid, latitude, longitude, countrycode, region, city|
# first update the user record with the current location
u = User.find(user.id)
u.addr = addr
u.locidispid = locidispid
u.lat = latitude
u.lng = longitude
u.country = countrycode
u.state = region
u.city = city
u.save!
u = nil
}
count = @connman.create_connection(user.id, client_id, "1.1.1.1")
count.should == 1
@ -154,30 +119,7 @@ describe ConnectionManager do
cc.region.should eql('TX')
cc.countrycode.should eql('US')
x = User.find(user.id)
#x.ip_address.should eql("1.1.1.1")
x.addr.should == 0x01010101
x.locidispid.should == 17192000002
x.lat.should == 30.2076
x.lng.should == -97.8587
x.city.should eql('Austin')
x.state.should eql('TX')
x.country.should eql('US')
x = nil
@connman.reconnect(cc, nil, "33.1.2.3") { |addr, locidispid, latitude, longitude, countrycode, region, city|
# first update the user record with the current location
u = User.find(user.id)
u.addr = addr
u.locidispid = locidispid
u.lat = latitude
u.lng = longitude
u.country = countrycode
u.state = region
u.city = city
u.save!
u = nil
}
@connman.reconnect(cc, nil, "33.1.2.3")
cc = Connection.find_by_client_id!(client_id)
cc.connected?.should be_true
@ -190,17 +132,6 @@ describe ConnectionManager do
cc.region.should eql('TX')
cc.countrycode.should eql('US')
x = User.find(user.id)
#x.ip_address.should eql("33.1.2.3")
x.addr.should == 0x21010203
x.locidispid.should == 30350000003
x.lat.should == 29.7633
x.lng.should == -95.3633
x.city.should eql('Houston')
x.state.should eql('TX')
x.country.should eql('US')
x = nil
count = @connman.delete_connection(client_id)
count.should == 0

View File

@ -488,18 +488,7 @@ module JamWebsockets
context = nil
ConnectionManager.active_record_transaction do |connection_manager|
music_session_id, reconnected = connection_manager.reconnect(connection, reconnect_music_session_id, remote_ip) do |addr, locidispid, latitude, longitude, countrycode, region, city|
# update user
#user.ip_address = remote_ip
user.addr = addr
user.locidispid = locidispid
user.lat = latitude
user.lng = longitude
user.country = countrycode
user.state = region
user.city = city
user.save!(validate: false)
end
music_session_id, reconnected = connection_manager.reconnect(connection, reconnect_music_session_id, remote_ip)
context = @client_lookup[client_id]
if music_session_id.nil?
@ -540,17 +529,7 @@ module JamWebsockets
unless connection
# log this connection in the database
ConnectionManager.active_record_transaction do |connection_manager|
connection_manager.create_connection(user.id, client.client_id, remote_ip) do |conn, count, addr, locidispid, latitude, longitude, countrycode, region, city|
# first update the user record with the current location
user.addr = addr
user.locidispid = locidispid
user.lat = latitude
user.lng = longitude
user.country = countrycode
user.state = region
user.city = city;
user.save!(validation: false)
connection_manager.create_connection(user.id, client.client_id, remote_ip) do |conn, count|
if count == 1
Notification.send_friend_update(user.id, true, conn)
end