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