00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PEEKABOT_CLIENT_CONNECTION_HH_INCLUDED
00023 #define PEEKABOT_CLIENT_CONNECTION_HH_INCLUDED
00024
00025
00026 #include "Types.hh"
00027 #include "Connection.hh"
00028 #include "ActionSource.hh"
00029
00030 #include <boost/asio.hpp>
00031 #include <boost/shared_ptr.hpp>
00032 #include <boost/enable_shared_from_this.hpp>
00033
00034
00035 namespace peekabot
00036 {
00037 class Server;
00038 class ServerData;
00039 class Action;
00040
00049 class ClientConnection :
00050 public Connection,
00051 public ActionSource,
00052 public boost::enable_shared_from_this<ClientConnection>
00053 {
00054 public:
00055 static boost::shared_ptr<ClientConnection> create(
00056 Server &server,
00057 boost::asio::io_service &io_service);
00058
00059 virtual void start();
00060
00061 virtual void send_response(const boost::shared_ptr<Action> &action);
00062
00063 private:
00064 ClientConnection(
00065 Server &server,
00066 boost::asio::io_service &io_service);
00067
00068 void execute_action(
00069 boost::shared_ptr<Action> action,
00070 ServerData &sd);
00071
00072 protected:
00073 virtual boost::shared_ptr<Connection> ptr();
00074
00075 virtual void action_read(
00076 const boost::shared_ptr<Action> &action);
00077
00078 virtual void on_authenticated();
00079
00080 virtual void on_authentication_failed(
00081 protocol::AuthenticationResult reason);
00082
00083 private:
00084 Server &m_server;
00085 };
00086 }
00087
00088
00089 #endif // PEEKABOT_CLIENT_CONNECTION_HH_INCLUDED