00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef SCALESTACK_DATABASEPROXY_CLIENT_H
00025 #define SCALESTACK_DATABASEPROXY_CLIENT_H
00026
00027 #include <scalestack/network/stream.h>
00028
00029 namespace scalestack
00030 {
00031 namespace database_proxy
00032 {
00033
00034 class client_service;
00035 class connection;
00036
00037 class client: public network::stream
00038 {
00039 public:
00040
00041 client(client_service& creator);
00042
00046 void set_connection(database_proxy::connection* bound_connection,
00047 bool need_handshake);
00048
00052 void yield(void);
00053
00057 void connected(void);
00058
00062 size_t read(uint8_t* buffer, size_t size);
00063
00067 void continue_write(void);
00068
00072 void flush_write(void);
00073
00077 void error(void);
00078
00082 void run(void);
00083
00084 private:
00085
00089 client(const client&);
00090
00094 client& operator=(const client&);
00095
00100 size_t _connection_write(void);
00101
00102 enum
00103 {
00104 SERVER_HANDSHAKE_PACKET,
00105 SERVER_HANDSHAKE_FLUSH,
00106 RESULT_PACKET,
00107 RESULT_FLUSH,
00108 COLUMN_PACKET,
00109 COLUMN_FLUSH,
00110 ROW_PACKET,
00111 ROW_FLUSH
00112 } _state, _next_state;
00113 bool _need_yield;
00114 bool _shutdown;
00115 size_t _size;
00116 size_t _packet_size;
00117 uint8_t* _buffer;
00118 database_proxy::connection* _connection;
00119 };
00120
00121 }
00122 }
00123
00124 #endif