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>
44print_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;
99 printf(
"Finalizing\n");
119 if (just_connected) {
120 just_connected =
false;
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) {
149 char *line = readline(prompt);
151 if (strcmp(line,
"") != 0) {
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;
229main(
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.
const std::vector< const char * > & items() const
Get non-option items.
bool parse_hostport(const char *argn, char **host, unsigned short int *port)
Parse host:port string.
std::vector< constchar * >::size_type num_items() const
Get number of non-option items.
The BlackBoard abstract class.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
virtual void close(Interface *interface)=0
Close interface.
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
Message handler for FawkesNetworkClient.
Simple Fawkes network client.
void register_handler(FawkesNetworkClientHandler *handler, unsigned int component_id)
Register handler.
void connect()
Connect to remote.
void disconnect()
Disconnect socket.
void deregister_handler(unsigned int component_id)
Deregister handler.
bool connected() const noexcept
Check if connection is alive.
Representation of a message that is sent over the network.
unsigned int msgq_enqueue(Message *message, bool proxy=false)
Enqueue message at end of queue.
SetTestStringMessage Fawkes BlackBoard Interface Message.
TestInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
void exit()
Exit the thread.
@ OPMODE_CONTINUOUS
operate in continuous mode (default)
Fawkes library namespace.