Subversion Repositories HomeAutomation

Rev

Rev 1959 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *  Copyright (C) 2010  Mattias Runge
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #ifndef VM_PLUGIN_CONSOLE_H
  22. #define VM_PLUGIN_CONSOLE_H
  23.  
  24. #include <boost/shared_ptr.hpp>
  25. #include <set>
  26.  
  27. #include "logging/Logger.h"
  28. #include "net/Subscriber.h"
  29. #include "net/types.h"
  30. #include "common/Byteset.h"
  31.  
  32. #include "vm/Plugin.h"
  33.  
  34. namespace atom {
  35. namespace vm {
  36. namespace plugin {
  37.  
  38. class Console : public Plugin
  39. {
  40. public:
  41.     typedef boost::shared_ptr<Console> Pointer;
  42.    
  43.     Console(boost::asio::io_service& io_service, unsigned int port);
  44.     virtual ~Console();
  45.    
  46.     void InitializeDone();
  47.     void CallOutput(unsigned int request_id, std::string output);
  48.    
  49. private:
  50.     net::SocketId server_id_;
  51.     static net::SocketId current_client_id_;
  52.     std::set<net::SocketId> clients_;
  53.    
  54.     void SlotOnNewState(net::SocketId id, net::ClientState client_state);
  55.     void SlotOnNewClient(net::SocketId id, net::SocketId server_id);
  56.     void SlotOnNewData(net::SocketId id, common::Byteset data);
  57.    
  58.     void SlotOnNewStateHandler(net::SocketId id, net::ClientState client_state);
  59.     void SlotOnNewClientHandler(net::SocketId id, net::SocketId server_id);
  60.     void SlotOnNewDataHandler(net::SocketId id, common::Byteset data);
  61.    
  62.     static logging::Logger LOG;
  63.    
  64.     static Value Export_PromptRequest(const v8::Arguments& args);
  65.     static Value Export_AutoCompleteResponse(const v8::Arguments& args);
  66.     static Value Export_LogToClient(const v8::Arguments& args);
  67.     static Value Export_DisconnectClient(const v8::Arguments& args);
  68. };
  69.  
  70. }; // namespace plugin
  71. }; // namespace vm
  72. }; // namespace atom
  73.  
  74. #endif // VM_PLUGIN_CONSOLE_H
  75.