24 #include <fvutils/net/fuse_client.h>
26 #include <fvutils/net/fuse_transceiver.h>
27 #include <fvutils/net/fuse_message_queue.h>
28 #include <fvutils/net/fuse_message.h>
29 #include <fvutils/net/fuse_client_handler.h>
31 #include <core/threading/mutex.h>
32 #include <core/threading/wait_condition.h>
33 #include <core/exceptions/software.h>
34 #include <netcomm/socket/stream.h>
35 #include <netcomm/utils/exceptions.h>
38 #include <netinet/in.h>
42 using namespace fawkes;
44 namespace firevision {
64 FuseClient::FuseClient(
const char *hostname,
unsigned short int port,
68 __hostname = strdup(hostname);
77 __mutex =
new Mutex();
78 __recv_mutex =
new Mutex();
81 __greeting_mutex =
new Mutex();
85 __greeting_received =
false;
94 while ( ! __inbound_msgq->empty() ) {
97 __inbound_msgq->pop();
99 delete __inbound_msgq;
101 while ( ! __outbound_msgq->empty() ) {
104 __outbound_msgq->pop();
106 delete __outbound_msgq;
110 delete __recv_waitcond;
112 delete __greeting_mutex;
113 delete __greeting_waitcond;
121 __socket->
connect(__hostname, __port);
124 greetmsg->
version = htonl(FUSE_CURRENT_VERSION);
162 __recv_mutex->
lock();
223 __recv_mutex->
lock();
225 __recv_waitcond->
wait();
240 __recv_mutex->
lock();
242 __recv_waitcond->
wait();
255 __recv_mutex->
lock();
257 __recv_waitcond->
wait();
272 __socket->
poll(__wait_timeout , Socket::POLL_IN);
300 __inbound_msgq->
lock();
301 while ( ! __inbound_msgq->empty() ) {
304 if ( m->
type() == FUSE_MT_GREETING ) {
306 if ( ntohl(gm->
version) != FUSE_CURRENT_VERSION ) {
310 __greeting_mutex->
lock();
311 __greeting_received =
true;
313 __greeting_mutex->
unlock();
322 __inbound_msgq->pop();
340 __recv_mutex->
lock();
341 __recv_waitcond->
wait();
356 __greeting_mutex->
lock();
357 while (! __greeting_received) {
358 __greeting_waitcond->
wait();
360 __greeting_mutex->
unlock();