Rev 1741 | Rev 1986 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1741 | Rev 1959 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 31 | namespace atom { |
31 | namespace atom { |
| 32 | namespace vm { |
32 | namespace vm { |
| 33 | namespace plugin { |
33 | namespace plugin { |
| 34 | 34 | ||
| 35 | logging::Logger Console::LOG("vm::plugin::Console"); |
35 | logging::Logger Console::LOG("vm::plugin::Console"); |
| 36 | net:: |
36 | net::SocketId Console::current_client_id_; |
| 37 | 37 | ||
| 38 | Console::Console(boost::asio::io_service& io_service, unsigned int port) : Plugin(io_service) |
38 | Console::Console(boost::asio::io_service& io_service, unsigned int port) : Plugin(io_service) |
| 39 | { |
39 | { |
| 40 | this->name_ = "console"; |
40 | this->name_ = "console"; |
| 41 | Console::current_client_id_ = 0; |
41 | Console::current_client_id_ = 0; |
| Line 82... | Line 82... | ||
| 82 | packet += output; |
82 | packet += output; |
| 83 | 83 | ||
| 84 | net::Manager::Instance()->SendTo(request_id, packet); |
84 | net::Manager::Instance()->SendTo(request_id, packet); |
| 85 | } |
85 | } |
| 86 | 86 | ||
| 87 | void Console::SlotOnNewData(net:: |
87 | void Console::SlotOnNewData(net::SocketId client_id, net::SocketId server_id, common::Byteset data) |
| 88 | { |
88 | { |
| 89 | if (server_id != this->server_id_) |
89 | if (server_id != this->server_id_) |
| 90 | { |
90 | { |
| 91 | return; |
91 | return; |
| 92 | } |
92 | } |
| 93 | 93 | ||
| 94 | this->io_service_.post(boost::bind(&Console::SlotOnNewDataHandler, this, client_id, server_id, data)); |
94 | this->io_service_.post(boost::bind(&Console::SlotOnNewDataHandler, this, client_id, server_id, data)); |
| 95 | } |
95 | } |
| 96 | 96 | ||
| 97 | void Console::SlotOnNewState(net:: |
97 | void Console::SlotOnNewState(net::SocketId client_id, net::SocketId server_id, net::ClientState client_state) |
| 98 | { |
98 | { |
| 99 | if (server_id != this->server_id_) |
99 | if (server_id != this->server_id_) |
| 100 | { |
100 | { |
| 101 | return; |
101 | return; |
| 102 | } |
102 | } |
| 103 | 103 | ||
| 104 | this->io_service_.post(boost::bind(&Console::SlotOnNewStateHandler, this, client_id, server_id, client_state)); |
104 | this->io_service_.post(boost::bind(&Console::SlotOnNewStateHandler, this, client_id, server_id, client_state)); |
| 105 | } |
105 | } |
| 106 | 106 | ||
| 107 | void Console::SlotOnNewDataHandler(net:: |
107 | void Console::SlotOnNewDataHandler(net::SocketId client_id, net::SocketId server_id, common::Byteset data) |
| 108 | { |
108 | { |
| 109 | v8::Locker lock; |
109 | v8::Locker lock; |
| 110 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
110 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 111 | v8::HandleScope handle_scope; |
111 | v8::HandleScope handle_scope; |
| 112 | 112 | ||
| Line 171... | Line 171... | ||
| 171 | } |
171 | } |
| 172 | 172 | ||
| 173 | Console::current_client_id_ = 0; |
173 | Console::current_client_id_ = 0; |
| 174 | } |
174 | } |
| 175 | 175 | ||
| 176 | void Console::SlotOnNewStateHandler(net:: |
176 | void Console::SlotOnNewStateHandler(net::SocketId client_id, net::SocketId server_id, net::ClientState client_state) |
| 177 | { |
177 | { |
| 178 | v8::Locker lock; |
178 | v8::Locker lock; |
| 179 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
179 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 180 | v8::HandleScope handle_scope; |
180 | v8::HandleScope handle_scope; |
| 181 | 181 | ||