Files
integration/luprex/core/cpp/main.cpp

37 lines
1.0 KiB
C++
Raw Normal View History

2020-11-12 14:24:33 -05:00
2021-01-22 19:10:47 -05:00
#include "textgame.hpp"
#include "driver.hpp"
#include "drivenengine.hpp"
class TNTest : public DrivenEngine {
public:
std::unique_ptr<Channel> chan_;
virtual void event_init() {
chan_ = new_outgoing_channel("stanford.edu:80");
chan_->out()->write_bytes("GET /index.html HTTP/1.1\n\n");
}
virtual void event_update() {
std::string input = get_stdio_channel()->in()->read_entire_contents();
if (input != "") {
get_stdio_channel()->out()->write_bytes("stdin: ");
get_stdio_channel()->out()->write_bytes(input);
}
if (chan_ != nullptr) {
if (chan_->closed()) {
get_stdio_channel()->out()->write_bytes("Connection closed.\n");
chan_.reset();
} else {
chan_->in()->copy_into(get_stdio_channel()->out());
chan_->in()->clear();
}
}
}
};
2020-11-12 14:24:33 -05:00
int main(int argc, char **argv)
{
//TextGame tg;
TNTest tg;
driver_drive(&tg);
2020-11-12 14:24:33 -05:00
}