5 #include <boost/uuid/uuid.hpp>
6 #include <websocketpp/server.hpp>
7 #include <websocketpp/config/asio_no_tls.hpp>
8 #include <websocketpp/common/functional.hpp>
10 #include <boost/python.hpp>
35 Server(
const std::string& socket);
54 void write(
const std::string& txt);
56 std::string
str()
const;
71 void on_socket_init(websocketpp::connection_hdl hdl, boost::asio::ip::tcp::socket & s);
73 void on_open(websocketpp::connection_hdl hdl);
74 void on_close(websocketpp::connection_hdl hdl);
87 websocketpp::connection_hdl
hdl;
90 typedef std::map<websocketpp::connection_hdl,
Connection,
108 Block(websocketpp::connection_hdl,
const std::string&, uint64_t
id);
109 websocketpp::connection_hdl
hdl;
121 std::string
run_string(
const std::string&,
bool handle_output=
true);
136 bool handles(
const std::string& otype)
const;
156 uint64_t
send(
const std::string& output,
const std::string& msg_type, uint64_t parent_id=0,
bool last_in_sequence=
false);
165 std::future<std::string>
job;
171 void dispatch_message(websocketpp::connection_hdl,
const std::string& json_string);
void on_socket_init(websocketpp::connection_hdl hdl, boost::asio::ip::tcp::socket &s)
Definition: Server.cc:217
void on_kernel_fault(Block)
Definition: Server.cc:458
Definition: Server.hh:106
Object representing a Cadabra server, capable of receiving messages on a websocket, running Python code, and sending output back to the client.
Definition: Server.hh:31
std::string error
Definition: Server.hh:112
int cells_ran
Definition: Server.hh:177
std::string run_string(const std::string &, bool handle_output=true)
Definition: Server.cc:163
boost::python::object main_module
Definition: Server.hh:174
std::mutex ws_mutex
Definition: Server.hh:96
~Server()
Definition: Server.cc:52
void write(const std::string &txt)
Definition: Server.cc:65
websocketpp::config::asio_client::message_type::ptr message_ptr
Definition: ComputeThread.hh:12
Definition: ProgressMonitor.hh:10
void on_block_error(Block)
Definition: Server.cc:432
void on_open(websocketpp::connection_hdl hdl)
Definition: Server.cc:228
void on_block_finished(Block)
Called by the run_block() thread upon completion of the task.
Definition: Server.cc:381
std::thread runner
Definition: Server.hh:100
Definition: Stopwatch.hh:32
void send_json(const std::string &)
Definition: Server.cc:425
std::string socket_name
Definition: Server.hh:76
void dispatch_message(websocketpp::connection_hdl, const std::string &json_string)
Takes a JSON encoded message and performs the required action to process it.
Definition: Server.cc:335
CatchOutput catchOut
Definition: Server.hh:61
std::string input
Definition: Server.hh:110
uint64_t send(const std::string &output, const std::string &msg_type, uint64_t parent_id=0, bool last_in_sequence=false)
Raw code to send a string (which must be JSON formatted) as a message to the client.
Definition: Server.cc:392
boost::python::object main_namespace
Definition: Server.hh:175
std::condition_variable block_available
Definition: Server.hh:102
bool started
Definition: Server.hh:164
std::string collect
Definition: Server.hh:58
void wait_for_job()
Definition: Server.cc:252
uint64_t cell_id
Definition: Server.hh:113
Python output catching.
Definition: Server.hh:49
CatchOutput()
Definition: Server.cc:57
std::string str() const
Definition: Server.cc:77
std::queue< Block > block_queue
Definition: Server.hh:115
uint64_t return_cell_id
Definition: Server.hh:159
void on_close(websocketpp::connection_hdl hdl)
Definition: Server.cc:237
WebsocketServer wserver
Definition: Server.hh:75
void on_message(websocketpp::connection_hdl hdl, WebsocketServer::message_ptr msg)
Definition: Server.cc:320
bool handles(const std::string &otype) const
Definition: Server.cc:386
void stop_block()
Halt the currently running block and prevent execution of any further blocks that may still be on the...
Definition: Server.cc:307
void clear()
Definition: Server.cc:71
uint64_t current_id
Definition: Server.hh:117
CatchOutput catchErr
Definition: Server.hh:61
websocketpp::connection_hdl current_hdl
Definition: Server.hh:116
std::map< websocketpp::connection_hdl, Connection, std::owner_less< websocketpp::connection_hdl > > ConnectionMap
Definition: Server.hh:91
void run()
The only user-visible part: just instantiate a server object and start it with run().
Definition: Server.cc:484
std::mutex block_available_mutex
Definition: Server.hh:101
Server()
Definition: Server.cc:37
void init()
Definition: Server.cc:87
websocketpp::connection_hdl hdl
Definition: Server.hh:109
Stopwatch server_stopwatch
Definition: Server.hh:63
websocketpp::connection_hdl hdl
Definition: Server.hh:87
std::future< std::string > job
Definition: Server.hh:165
std::string architecture() const
Definition: Server.cc:82
Connection()
Definition: Server.cc:223
std::string output
Definition: Server.hh:111
Stopwatch sympy_stopwatch
Definition: Server.hh:64
Block(websocketpp::connection_hdl, const std::string &, uint64_t id)
Definition: Server.cc:315
websocketpp::server< websocketpp::config::asio > WebsocketServer
Definition: Server.hh:70
boost::uuids::uuid uuid
Definition: Server.hh:88
ConnectionMap connections
Definition: Server.hh:92