Adapt output buffering to Poseidon and DCP

* Refactor flushing of messages
* Introduce two separate buffers for stdout and stderr
This commit is contained in:
Sebastian Serth
2021-10-17 13:15:52 +02:00
parent 1891cdd69c
commit 345860c779
3 changed files with 24 additions and 22 deletions

View File

@ -96,14 +96,11 @@ class SubmissionsController < ApplicationController
end
client_socket.onmessage do |raw_event|
event = if raw_event == "\n"
# Obviously, this is just flushing the current connection.
# We temporarily wrap it and then forward the original event intentionally.
{cmd: 'result'}
else
# We expect to receive a JSON
JSON.parse(raw_event).deep_symbolize_keys
end
# Obviously, this is just flushing the current connection: Filtering.
next if raw_event == "\n"
# Otherwise, we expect to receive a JSON: Parsing.
event = JSON.parse(raw_event).deep_symbolize_keys
case event[:cmd].to_sym
when :client_kill