Merge branch 'develop' into feature/sprint_12_work
This commit is contained in:
commit
9ae3fb1f45
|
|
@ -5,7 +5,7 @@ ActiveAdmin.register_page "Current Scoring Load" do
|
|||
table_for GetWork.summary do
|
||||
column "Work", :work_count
|
||||
column "Who", Proc.new { |connection| "#{connection.first_name} #{connection.last_name} - #{connection.email}" }
|
||||
column "Errors", Proc.new { |connection| "#{connection.udp_reachable != 'f' ? "" : "No STUN"} #{connection.in_timeout != 'f' ? "in timeout," : ""} #{connection.in_session != 'f' ? "in session" : ""}" }
|
||||
column "Errors", Proc.new { |connection| "#{connection.udp_reachable != false ? "" : "No STUN,"} #{connection.in_timeout != 'f' ? "Timeout," : ""} #{connection.in_session != 'f' ? "In-Session," : ""}" }
|
||||
column "Total Timeouts", :scoring_timeout_occurrences
|
||||
column "Current Scoring Failures", :scoring_failures
|
||||
column "Offset", :scoring_failures_offset
|
||||
|
|
|
|||
|
|
@ -84,8 +84,12 @@ module JamRuby
|
|||
conn.save!(validate: false)
|
||||
end
|
||||
|
||||
# if udp_reachable is nil, it means it's unknown. Since this is a reconnect, we'll, preserve existing value in this case
|
||||
# otherwise, pass in the value of boolean udp_reachable var
|
||||
udp_reachable_value = udp_reachable.nil? ? 'udp_reachable' : udp_reachable
|
||||
|
||||
sql =<<SQL
|
||||
UPDATE connections SET (channel_id, aasm_state, updated_at, music_session_id, joined_session_at, stale_time, expire_time, udp_reachable) = ('#{channel_id}', '#{Connection::CONNECT_STATE.to_s}', NOW(), #{music_session_id_expression}, #{joined_session_at_expression}, #{connection_stale_time}, #{connection_expire_time}, #{udp_reachable})
|
||||
UPDATE connections SET (channel_id, aasm_state, updated_at, music_session_id, joined_session_at, stale_time, expire_time, udp_reachable) = ('#{channel_id}', '#{Connection::CONNECT_STATE.to_s}', NOW(), #{music_session_id_expression}, #{joined_session_at_expression}, #{connection_stale_time}, #{connection_expire_time}, #{udp_reachable_value})
|
||||
WHERE
|
||||
client_id = '#{conn.client_id}'
|
||||
RETURNING music_session_id
|
||||
|
|
|
|||
|
|
@ -104,14 +104,56 @@ describe ConnectionManager, no_transaction: true do
|
|||
cc.ip_address.should eql("1.1.1.1")
|
||||
cc.addr.should == 0x01010101
|
||||
cc.locidispid.should == 17192000002
|
||||
cc.udp_reachable.should == true
|
||||
|
||||
@connman.reconnect(cc, channel_id, nil, "33.1.2.3", STALE_TIME, EXPIRE_TIME, REACHABLE)
|
||||
@connman.reconnect(cc, channel_id, nil, "33.1.2.3", STALE_TIME, EXPIRE_TIME, false)
|
||||
|
||||
cc = Connection.find_by_client_id!(client_id)
|
||||
cc.connected?.should be_true
|
||||
cc.ip_address.should eql("33.1.2.3")
|
||||
cc.addr.should == 0x21010203
|
||||
cc.locidispid.should == 30350000003
|
||||
cc.udp_reachable.should == false
|
||||
|
||||
count = @connman.delete_connection(client_id)
|
||||
count.should == 0
|
||||
|
||||
@conn.exec("SELECT count(*) FROM connections where user_id = $1", [user.id]) do |result|
|
||||
result.getvalue(0, 0).to_i.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
it "create connection, reconnect via heartbeat" do
|
||||
|
||||
client_id = "client_id3"
|
||||
#user_id = create_user("test", "user2", "user2@jamkazam.com")
|
||||
user = FactoryGirl.create(:user)
|
||||
|
||||
count = @connman.create_connection(user.id, client_id, channel_id, "1.1.1.1", 'client', STALE_TIME, EXPIRE_TIME, false)
|
||||
|
||||
count.should == 1
|
||||
|
||||
# make sure the connection is seen
|
||||
|
||||
@conn.exec("SELECT count(*) FROM connections where user_id = $1", [user.id]) do |result|
|
||||
result.getvalue(0, 0).to_i.should == 1
|
||||
end
|
||||
|
||||
cc = Connection.find_by_client_id!(client_id)
|
||||
cc.connected?.should be_true
|
||||
cc.ip_address.should eql("1.1.1.1")
|
||||
cc.addr.should == 0x01010101
|
||||
cc.locidispid.should == 17192000002
|
||||
cc.udp_reachable.should == false
|
||||
|
||||
@connman.reconnect(cc, channel_id, nil, "33.1.2.3", STALE_TIME, EXPIRE_TIME, nil) # heartbeat passes nil in for udp_reachable
|
||||
|
||||
cc = Connection.find_by_client_id!(client_id)
|
||||
cc.connected?.should be_true
|
||||
cc.ip_address.should eql("33.1.2.3")
|
||||
cc.addr.should == 0x21010203
|
||||
cc.locidispid.should == 30350000003
|
||||
cc.udp_reachable.should == false
|
||||
|
||||
count = @connman.delete_connection(client_id)
|
||||
count.should == 0
|
||||
|
|
|
|||
|
|
@ -11,4 +11,3 @@ $ rake jasmine
|
|||
|
||||
Open browser to localhost:8888
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -542,6 +542,7 @@
|
|||
|
||||
server.connecting = true;
|
||||
server.socket = new context.WebSocket(uri);
|
||||
server.socket.channelId = channelId;
|
||||
server.socket.onopen = server.onOpen;
|
||||
server.socket.onmessage = server.onMessage;
|
||||
server.socket.onclose = server.onClose;
|
||||
|
|
@ -620,6 +621,13 @@
|
|||
server.onClose = function () {
|
||||
logger.info("Socket to server closed.");
|
||||
|
||||
var disconnectedSocket = this;
|
||||
|
||||
if(disconnectedSocket.channelId != server.socket.channelId) {
|
||||
logger.debug(" ignoring disconnect for non-current socket. current=" + server.socket.channelId + ", disc=" + disconnectedSocket.channelId)
|
||||
return;
|
||||
}
|
||||
|
||||
if (connectDeferred.state() === "pending") {
|
||||
connectDeferred.reject();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
var logger = context.JK.logger;
|
||||
var ellipsesJiggleTimer = null;
|
||||
var forceShow = false; // manual test helper
|
||||
// updated once a download is started
|
||||
var updateUri = null;
|
||||
var updateSize = 0;
|
||||
app.clientUpdating = false;
|
||||
|
||||
// updated once a download is started
|
||||
var updateSize = 0;
|
||||
|
||||
function cancelUpdate(e) {
|
||||
if ((e.ctrlKey || e.metaKey) && e.keyCode == 78) {
|
||||
|
|
@ -27,8 +27,10 @@
|
|||
// responsible for updating the contents of the update dialog
|
||||
// as well as registering for any event handlers
|
||||
function updateClientUpdateDialog(templateId, options) {
|
||||
options = options || {};
|
||||
|
||||
var template = $('#template-' + templateId).html();
|
||||
var templateHtml = context.JK.fillTemplate(template, options);
|
||||
var templateHtml = context._.template(template, options, {variable: 'data'});
|
||||
|
||||
$('#client_update .dialog-inner').html(templateHtml);
|
||||
|
||||
|
|
@ -69,12 +71,13 @@
|
|||
/***************************************/
|
||||
function clientUpdateDownloadProgress(bytesReceived, bytesTotal, downloadSpeedMegSec, timeRemaining) {
|
||||
// this fires way too many times to leave in. uncomment if debugging update feature
|
||||
//logger.debug("bytesReceived: " + bytesReceived, ", bytesTotal: " + bytesTotal, ", downloadSpeed: " + downloadSpeedMegSec, ", timeRemaining: " + timeRemaining );
|
||||
//logger.debug("bytesReceived: " + bytesReceived, ", bytesTotal: " + bytesTotal, ", downloadSpeed: " + downloadSpeedMegSec, ", timeRemaining: " + timeRemaining + ", updateSize: " + updateSize);
|
||||
|
||||
bytesReceived = Number(bytesReceived)
|
||||
bytesTotal = Number(bytesTotal)
|
||||
// bytesTotal from Qt is not trust worthy; trust server's answer instead
|
||||
$('#progress-bar').width(((bytesReceived / updateSize) * 100).toString() + "%")
|
||||
var progressWidth = ((bytesReceived / updateSize) * 100).toString() + "%";
|
||||
$('#progress-bar').width(progressWidth)
|
||||
//$("#progressbar_detail").text(parseInt(bytesReceived) + "/" + parseInt(updateSize))
|
||||
}
|
||||
|
||||
|
|
@ -98,10 +101,27 @@
|
|||
}
|
||||
|
||||
|
||||
function clientUpdateLaunchSuccess(updateLocation) {
|
||||
logger.debug("client update launched successfully to: " + updateLocation);
|
||||
function clientUpdateLaunchSuccess(userTimeToRead) {
|
||||
if(userTimeToRead === undefined) {
|
||||
userTimeToRead = 1000; // older clients didn't pass this in, and exit very quickly
|
||||
}
|
||||
|
||||
updateClientUpdateDialog("update-restarting");
|
||||
logger.debug("client update launching in: " + userTimeToRead);
|
||||
|
||||
// set timer to update countdown
|
||||
var rounded = Math.round(userTimeToRead / 1000);
|
||||
|
||||
// simple countdown timer
|
||||
var timer = setInterval(function(){
|
||||
var $countdown = $('#client_update .countdown-secs');
|
||||
var countdown = parseInt($countdown.text());
|
||||
$countdown.text(countdown - 1);
|
||||
if(countdown == 0) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, rounded * 1000);
|
||||
|
||||
updateClientUpdateDialog("update-restarting", {countdown: rounded, os: context.JK.GetOSAsString()});
|
||||
}
|
||||
|
||||
function clientUpdateLaunchFailure(errorMsg) {
|
||||
|
|
@ -167,7 +187,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function runCheck(product, version, uri, updateSize, currentVersion) {
|
||||
function runCheck(product, version, uri, size, currentVersion) {
|
||||
|
||||
if(currentVersion === undefined) {
|
||||
currentVersion = context.jamClient.ClientUpdateVersion();
|
||||
|
|
@ -191,6 +211,7 @@
|
|||
if (shouldUpdate(currentVersion, version)) {
|
||||
app.clientUpdating = true;
|
||||
updateUri = uri;
|
||||
updateSize = size;
|
||||
|
||||
if(context.JK.CurrentSessionModel && context.JK.CurrentSessionModel.inSession()) {
|
||||
logger.debug("deferring client update because in session")
|
||||
|
|
@ -210,7 +231,7 @@
|
|||
// check if updated is needed
|
||||
function check() {
|
||||
|
||||
var os = context.jamClient.GetOSAsString();
|
||||
var os = context.JK.GetOSAsString();
|
||||
|
||||
// check kill switch before all other logic
|
||||
if (!gon.check_for_client_updates) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@
|
|||
display:block;
|
||||
}
|
||||
|
||||
.countdown-secs {
|
||||
font-size:24px;
|
||||
display:inline-block;
|
||||
width:15px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight:bold;
|
||||
font-size:x-large;
|
||||
|
|
|
|||
|
|
@ -75,8 +75,13 @@
|
|||
<br />
|
||||
<br />
|
||||
<div align="center">
|
||||
This application will close automatically in a moment.
|
||||
If it does not close, please restart it manually.
|
||||
{% if(data.os == 'MacOSX') { %}
|
||||
This application will close automatically in <span class="countdown-secs">{{data.countdown}}</span> {{data.countdown == 1 ? 'second' : 'seconds'}}.
|
||||
If it does not close, please restart it manually or download the latest JamKazam from <a href="/downloads" rel="external">our downloads page</a>.
|
||||
{% } else { %}
|
||||
The updater will launch automatically in <span class="countdown-secs">{{data.countdown}}</span> seconds.
|
||||
If you do not see a Windows updater, please restart it manually or download the latest JamKazam from <a href="/downloads" rel="external">our downloads page</a>.
|
||||
{% } %}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
@ -90,7 +95,7 @@
|
|||
<p class="fix">Download the latest JamKazam from <a href="/downloads" rel="external">our downloads page</a>.</p>
|
||||
</div>
|
||||
<div class="error-detail">
|
||||
{error_msg}
|
||||
{{data.error_msg}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ module JamWebsockets
|
|||
if connection.stale?
|
||||
ConnectionManager.active_record_transaction do |connection_manager|
|
||||
heartbeat_interval, connection_stale_time, connection_expire_time = determine_connection_times(context.user, context.client_type)
|
||||
connection_manager.reconnect(connection, connection.music_session_id, nil, connection_stale_time, connection_expire_time, udp_reachable)
|
||||
connection_manager.reconnect(connection, client.channel_id, connection.music_session_id, nil, connection_stale_time, connection_expire_time, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue