also handle testcommand via websocket
This commit is contained in:
@ -350,13 +350,14 @@ $(function() {
|
|||||||
flowrOutputBuffer = '';
|
flowrOutputBuffer = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleTestResponse = function(response) {
|
var handleTestResponse = function(websocket_event) {
|
||||||
|
result = JSON.parse(websocket_event.data);
|
||||||
clearOutput();
|
clearOutput();
|
||||||
printOutput(response[0], false, 0);
|
printOutput(result, false, 0);
|
||||||
if (qa_api) {
|
if (qa_api) {
|
||||||
qa_api.executeCommand('syncOutput', [response]);
|
qa_api.executeCommand('syncOutput', [result]);
|
||||||
}
|
}
|
||||||
showStatus(response[0]);
|
showStatus(result);
|
||||||
showTab(1);
|
showTab(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -956,7 +957,7 @@ $(function() {
|
|||||||
createSubmission(this, null, function(response) {
|
createSubmission(this, null, function(response) {
|
||||||
showSpinner($('#test'));
|
showSpinner($('#test'));
|
||||||
var url = response.test_url.replace(FILENAME_URL_PLACEHOLDER, active_file.filename);
|
var url = response.test_url.replace(FILENAME_URL_PLACEHOLDER, active_file.filename);
|
||||||
evaluateCode(url, false, handleTestResponse);
|
evaluateCode(url, true, handleTestResponse);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -270,8 +270,14 @@ class SubmissionsController < ApplicationController
|
|||||||
private :store_error
|
private :store_error
|
||||||
|
|
||||||
def test
|
def test
|
||||||
|
hijack do |tubesock|
|
||||||
|
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
||||||
|
|
||||||
output = @docker_client.execute_test_command(@submission, params[:filename])
|
output = @docker_client.execute_test_command(@submission, params[:filename])
|
||||||
render(json: [output])
|
|
||||||
|
# tubesock is the socket to the client
|
||||||
|
tubesock.send_data JSON.dump(output)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_server_sent_events
|
def with_server_sent_events
|
||||||
|
Reference in New Issue
Block a user