24 #include <blackboard/remote.h>
25 #include <core/threading/thread.h>
26 #include <interfaces/TestInterface.h>
27 #include <netcomm/fawkes/client.h>
28 #include <netcomm/fawkes/client_handler.h>
29 #include <readline/history.h>
30 #include <readline/readline.h>
31 #include <utils/system/argparser.h>
32 #include <utils/system/signal.h>
44 print_usage(
const char *program_name)
46 printf(
"Usage: %s [-h] [-r host[:port]]\n"
47 " -h This help message\n"
48 " -r host[:port] Remote host (and optionally port) to connect to\n",
75 just_connected =
true;
76 connection_died_recently =
false;
81 rl_event_hook = event_hook;
83 char * host = (
char *)
"localhost";
84 unsigned short int port = 1910;
92 c->register_handler(
this, FAWKES_CID_SKILLER_PLUGIN);
99 printf(
"Finalizing\n");
110 c->deregister_handler(FAWKES_CID_SKILLER_PLUGIN);
118 if (c->connected()) {
119 if (just_connected) {
120 just_connected =
false;
123 testif = rbb->open_for_reading<
TestInterface>(
"eclipse_clp_skillexec");
131 if (argp->num_items() > 0) {
132 const std::vector<const char *> &items = argp->items();
134 std::vector<const char *>::const_iterator i = items.begin();
135 std::string sks = *i;
137 for (; i != items.end(); ++i) {
144 testif->msgq_enqueue(tsm);
149 char *line = readline(prompt);
151 if (strcmp(line,
"") != 0) {
154 testif->msgq_enqueue(tsm);
158 if (!connection_died_recently) {
164 if (connection_died_recently) {
165 connection_died_recently =
false;
166 printf(
"Connection died\n");
199 connection_died_recently =
true;
209 printf(
"Connection established\n");
210 just_connected =
true;
221 bool connection_died_recently;
229 main(
int argc,
char **argv)
233 if (argp.has_arg(
"h")) {
234 print_usage(argv[0]);
virtual void deregistered(unsigned int id) noexcept
This handler has been deregistered.
SkillShellThread(ArgumentParser *argp)
Constructor.
virtual void loop()
Code to execute in the thread.
~SkillShellThread()
Destructor.
virtual void inbound_received(FawkesNetworkMessage *m, unsigned int id) noexcept
Called for incoming messages.
virtual void connection_died(unsigned int id) noexcept
Client connection died.
virtual void connection_established(unsigned int id) noexcept
Client has established a connection.
Parse command line arguments.
bool parse_hostport(const char *argn, char **host, unsigned short int *port)
Parse host:port string.
The BlackBoard abstract class.
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
Message handler for FawkesNetworkClient.
Simple Fawkes network client.
Representation of a message that is sent over the network.
SetTestStringMessage Fawkes BlackBoard Interface Message.
TestInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Fawkes library namespace.