• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

src/ClientConnection.hh

00001 /*
00002  * Copyright Staffan Gimåker 2010.
00003  *
00004  * ---
00005  *
00006  * This file is part of peekabot.
00007  *
00008  * peekabot is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * peekabot is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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

Generated on Sun Jan 30 2011 for peekabot by  doxygen 1.7.1