Subversion Repositories HomeAutomation

Rev

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

Rev Author Line No. Line
1608 runge 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
 
1619 runge 21
#ifndef VM_PLUGIN_CONSOLE_H
22
#define VM_PLUGIN_CONSOLE_H
1608 runge 23
 
24
#include <boost/shared_ptr.hpp>
1986 runge 25
#include <set>
1608 runge 26
 
27
#include "logging/Logger.h"
28
#include "net/Subscriber.h"
29
#include "net/types.h"
1642 runge 30
#include "common/Byteset.h"
1608 runge 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
 
1625 runge 43
    Console(boost::asio::io_service& io_service, unsigned int port);
1608 runge 44
    virtual ~Console();
45
 
46
    void InitializeDone();
1647 runge 47
    void CallOutput(unsigned int request_id, std::string output);
1608 runge 48
 
49
private:
1959 runge 50
    net::SocketId server_id_;
51
    static net::SocketId current_client_id_;
1986 runge 52
    std::set<net::SocketId> clients_;
1608 runge 53
 
1986 runge 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);
1608 runge 57
 
1986 runge 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);
1625 runge 61
 
1608 runge 62
    static logging::Logger LOG;
63
 
1647 runge 64
    static Value Export_PromptRequest(const v8::Arguments& args);
65
    static Value Export_AutoCompleteResponse(const v8::Arguments& args);
1657 runge 66
    static Value Export_LogToClient(const v8::Arguments& args);
1664 runge 67
    static Value Export_DisconnectClient(const v8::Arguments& args);
1608 runge 68
};
69
 
70
}; // namespace plugin
71
}; // namespace vm
72
}; // namespace atom
73
 
1619 runge 74
#endif // VM_PLUGIN_CONSOLE_H