Compare commits

..

3 Commits

3 changed files with 10 additions and 6 deletions

View File

@ -7,6 +7,8 @@ auto sliger::rpc::action::RunDebug::perform_action(
{ {
auto program = this->instructions; auto program = this->instructions;
vm.load_and_run(program); vm.load_and_run(program);
writer->write("{ \"ok\": true }");
writer->flush();
}; };
auto sliger::rpc::action::FlameGraph::perform_action( auto sliger::rpc::action::FlameGraph::perform_action(
@ -15,10 +17,10 @@ auto sliger::rpc::action::FlameGraph::perform_action(
{ {
auto json = vm.flame_graph_json(); auto json = vm.flame_graph_json();
if (json) { if (json) {
writer->write( writer->write(std::format(
std::format("{{ ok: true, flameGraph: \"{}\" }}", json.value())); "{{ \"ok\": true, \"flameGraph\": \"{}\" }}", json.value()));
} else { } else {
writer->write("null"); writer->write("{ \"ok\": false }");
} }
writer->flush(); writer->flush();
}; };
@ -29,10 +31,10 @@ auto sliger::rpc::action::CodeCoverage::perform_action(
{ {
auto json = vm.code_coverage_json(); auto json = vm.code_coverage_json();
if (json) { if (json) {
writer->write( writer->write(std::format(
std::format("{{ ok: true, codeCoverage: \"{}\" }}", json.value())); "{{ \"ok\": true, \"codeCoverage\": \"{}\" }}", json.value()));
} else { } else {
writer->write("{ ok: false }"); writer->write("{ \"ok\": false }");
} }
writer->flush(); writer->flush();
}; };

View File

@ -56,6 +56,7 @@ int main(int argc, char** argv)
action->perform_action(std::move(writer), state); action->perform_action(std::move(writer), state);
}); });
std::cout << "binding on 127.0.0.1:13370\n";
auto res = rpc.listen(); auto res = rpc.listen();
if (!res.is_ok()) { if (!res.is_ok()) {
std::cout << res.err().msg << "\n"; std::cout << res.err().msg << "\n";

View File

@ -23,6 +23,7 @@ auto sliger::rpc::BufferedWriter::write(uint8_t byte) -> Res<Unit>
} }
} }
this->buffer[this->occupied] = byte; this->buffer[this->occupied] = byte;
this->occupied += 1;
return Unit {}; return Unit {};
} }