1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include "subprocess.h" using namespace godot; #include <iostream> #include <sstream> using namespace godot; void Subprocess::_register_methods() { register_signal<Subprocess>((char *)"recieve", "text", GODOT_VARIANT_STRING); register_method("send", &Subprocess::send); } void Subprocess::_init() { String line; bool running = true; while (running && getline(std::cin, line)) { std::istringstream iss(line); Godot::print(line); } } static void Subprocess::send(const String &text) { std::cout << text << std::endl; }