Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2107 | runge | 1 | /* |
| 2 | * |
||
| 3 | * Copyright (C) 2012 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_JSPIPE_H |
||
| 22 | #define VM_PLUGIN_JSPIPE_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 JsPipe : public Plugin |
||
| 39 | { |
||
| 40 | public: |
||
| 41 | typedef boost::shared_ptr<JsPipe> Pointer; |
||
| 42 | |||
| 43 | JsPipe(boost::asio::io_service& io_service, unsigned int port); |
||
| 44 | virtual ~JsPipe(); |
||
| 45 | |||
| 46 | void InitializeDone(); |
||
| 47 | void CallResult(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 Value Export_DisconnectClient(const v8::Arguments& args); |
||
| 63 | }; |
||
| 64 | |||
| 65 | }; // namespace plugin |
||
| 66 | }; // namespace vm |
||
| 67 | }; // namespace atom |
||
| 68 | |||
| 69 | #endif // VM_PLUGIN_JSPIPE_H |