Intra2net AG

command_client.hxx

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
00003 
00004 The software in this package is distributed under the GNU General
00005 Public License version 2 (with a special exception described below).
00006 
00007 A copy of GNU General Public License (GPL) is included in this distribution,
00008 in the file COPYING.GPL.
00009 
00010 As a special exception, if other files instantiate templates or use macros
00011 or inline functions from this file, or you compile this file and link it
00012 with other works to produce a work based on this file, this file
00013 does not by itself cause the resulting work to be covered
00014 by the GNU General Public License.
00015 
00016 However the source code for this file must still be made available
00017 in accordance with section (3) of the GNU General Public License.
00018 
00019 This exception does not invalidate any other reasons why a work based
00020 on this file might be covered by the GNU General Public License.
00021 */
00022 #ifndef __LIBT2N_COMMAND_CLIENT
00023 #define __LIBT2N_COMMAND_CLIENT
00024 
00025 #include <functional>
00026 #include <string>
00027 
00028 #include "client.hxx"
00029 #include "container.hxx"
00030 
00031 namespace libt2n
00032 {
00033 
00035 class command_client
00036 {
00037     public:
00038         static const long long command_timeout_usec_default=90000000;
00039         static const long long hello_timeout_usec_default=30000000;
00040 
00041     private:
00042         client_connection *c;
00043 
00044         long long hello_timeout_usec;
00045         long long command_timeout_usec;
00046 
00047         void read_hello();
00048         std::string read_packet(const long long &usec_timeout);
00049         bool check_hello(const std::string& hellostr);
00050 
00051         t2n_exception *constructorException;
00052 
00053     public:
00054         command_client(client_connection* _c,
00055             long long _command_timeout_usec=command_timeout_usec_default,
00056             long long _hello_timeout_usec=hello_timeout_usec_default);
00057         virtual ~command_client();
00058 
00059         void replace_connection(client_connection* _c);
00060 
00061         void send_command(command* cmd, result_container &res);
00062 
00063         void set_command_timeout_usec(long long _command_timeout_usec=command_timeout_usec_default)
00064             { command_timeout_usec=_command_timeout_usec; }
00065         void set_hello_timeout_usec(long long _hello_timeout_usec=hello_timeout_usec_default)
00066             { hello_timeout_usec=_hello_timeout_usec; }
00067         long long get_command_timeout_usec(void)
00068             { return command_timeout_usec; }
00069         long long get_hello_timeout_usec(void)
00070             { return hello_timeout_usec; }
00071         bool is_connection_closed(void)
00072             { return c->is_closed(); }
00073         t2n_exception* get_constuctor_exception(void)
00074             { return constructorException; }
00075 };
00076 
00077 }
00078 
00079 #endif
00080 

Generated on 13 May 2015 by  doxygen 1.6.1
© Intra2net AG 2024 | Legal | Contact