23 #include <blackboard/remote.h>
24 #include <core/threading/thread.h>
25 #include <interfaces/SkillerInterface.h>
26 #include <netcomm/fawkes/client.h>
27 #include <netcomm/fawkes/client_handler.h>
28 #include <readline/history.h>
29 #include <readline/readline.h>
30 #include <utils/system/argparser.h>
31 #include <utils/system/signal.h>
43 print_usage(
const char *program_name)
45 printf(
"Usage: %s [-h] [-r host[:port]]\n"
46 " -h This help message\n"
47 " -r host[:port] Remote host (and optionally port) to connect to\n",
74 just_connected =
true;
75 connection_died_recently =
false;
80 rl_event_hook = event_hook;
82 char * host = (
char *)
"localhost";
83 unsigned short int port = 1910;
91 c->register_handler(
this, FAWKES_CID_SKILLER_PLUGIN);
98 printf(
"Finalizing\n");
101 sif->msgq_enqueue(rcm);
109 c->deregister_handler(FAWKES_CID_SKILLER_PLUGIN);
117 if (c->connected()) {
118 if (just_connected) {
119 just_connected =
false;
125 sif->msgq_enqueue(aqm);
133 if (argp->num_items() > 0) {
135 const std::vector<const char *> &items = argp->items();
137 std::vector<const char *>::const_iterator i = items.begin();
140 for (; i != items.end(); ++i) {
147 sif->msgq_enqueue(esm);
152 char *line = readline(prompt);
154 if (strcmp(line,
"") != 0) {
155 if (strcmp(line,
"stop") == 0) {
156 printf(
"Stopping skill execution\n");
158 sif->msgq_enqueue(sm);
160 printf(
"Executing: %s\n", line);
163 sif->msgq_enqueue(esm);
169 if (!connection_died_recently) {
175 if (connection_died_recently) {
176 connection_died_recently =
false;
177 printf(
"Connection died\n");
210 connection_died_recently =
true;
220 printf(
"Connection established\n");
221 just_connected =
true;
232 bool connection_died_recently;
240 main(
int argc,
char **argv)
244 if (argp.has_arg(
"h")) {
245 print_usage(argv[0]);