24 #include <netcomm/fawkes/client.h> 25 #include <blackboard/remote.h> 26 #include <utils/system/argparser.h> 27 #include <utils/system/signal.h> 28 #include <core/threading/thread.h> 29 #include <netcomm/fawkes/client_handler.h> 38 #include <readline/readline.h> 39 #include <readline/history.h> 41 #include <interfaces/TestInterface.h> 46 print_usage(
const char *program_name)
48 printf(
"Usage: %s [-h] [-r host[:port]]\n" 49 " -h This help message\n" 50 " -r host[:port] Remote host (and optionally port) to connect to\n",
78 just_connected =
true;
79 connection_died_recently =
false;
84 rl_event_hook = event_hook;
86 char *host = (
char *)
"localhost";
87 unsigned short int port = 1910;
92 if ( free_host ) free(host);
94 c->register_handler(
this, FAWKES_CID_SKILLER_PLUGIN);
101 printf(
"Finalizing\n");
112 c->deregister_handler(FAWKES_CID_SKILLER_PLUGIN);
120 if ( c->connected() ) {
121 if ( just_connected ) {
122 just_connected =
false;
125 testif = rbb->open_for_reading<
TestInterface>(
"eclipse_clp_skillexec");
133 if ( argp->num_items() > 0 ) {
134 std::string sks =
"";
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) {
146 testif->msgq_enqueue(tsm);
153 line = readline(prompt);
155 if (strcmp(line,
"") != 0) {
157 testif->msgq_enqueue(tsm);
161 if ( ! connection_died_recently ) {
167 if ( connection_died_recently ) {
168 connection_died_recently =
false;
169 printf(
"Connection died\n");
189 unsigned int id)
throw()
203 connection_died_recently =
true;
213 printf(
"Connection established\n");
214 just_connected =
true;
226 bool connection_died_recently;
235 main(
int argc,
char **argv)
240 print_usage(argv[0]);
Message handler for FawkesNetworkClient.
SkillShellThread(ArgumentParser *argp)
Constructor.
virtual void deregistered(unsigned int id)
This handler has been deregistered.
bool parse_hostport(const char *argn, char **host, unsigned short int *port)
Parse host:port string.
Simple Fawkes network client.
Fawkes library namespace.
Representation of a message that is sent over the network.
Parse command line arguments.
Thread class encapsulation of pthreads.
Base class for exceptions in Fawkes.
virtual void connection_established(unsigned int id)
Client has established a connection.
void print_trace()
Prints trace to stderr.
virtual void loop()
Code to execute in the thread.
virtual void connection_died(unsigned int id)
Client connection died.
void join()
Join the thread.
bool has_arg(const char *argn)
Check if argument has been supplied.
The BlackBoard abstract class.
~SkillShellThread()
Destructor.
SetTestStringMessage Fawkes BlackBoard Interface Message.
virtual void inbound_received(FawkesNetworkMessage *m, unsigned int id)
Called for incoming messages.
void start(bool wait=true)
Call this method to start the thread.
TestInterface Fawkes BlackBoard Interface.