Rev 1740 | Rev 1898 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1740 | Rev 1741 | ||
|---|---|---|---|
| Line 77... | Line 77... | ||
| 77 | 77 | ||
| 78 | void Socket::SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, common::Byteset data) |
78 | void Socket::SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, common::Byteset data) |
| 79 | { |
79 | { |
| 80 | v8::Locker lock; |
80 | v8::Locker lock; |
| 81 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
81 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 82 | v8::HandleScope handle_scope; |
|
| 82 | 83 | ||
| 83 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
84 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 84 | 85 | ||
| 85 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
86 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
| 86 | arguments->push_back(v8::Integer::New(client_id)); |
87 | arguments->push_back(v8::Integer::New(client_id)); |
| Line 91... | Line 92... | ||
| 91 | 92 | ||
| 92 | void Socket::SlotOnNewStateHandler(net::ClientId client_id, net::ServerId server_id, net::ClientState client_state) |
93 | void Socket::SlotOnNewStateHandler(net::ClientId client_id, net::ServerId server_id, net::ClientState client_state) |
| 93 | { |
94 | { |
| 94 | v8::Locker lock; |
95 | v8::Locker lock; |
| 95 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
96 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 97 | v8::HandleScope handle_scope; |
|
| 96 | 98 | ||
| 97 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
99 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 98 | 100 | ||
| 99 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
101 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
| 100 | arguments->push_back(v8::Integer::New(client_id)); |
102 | arguments->push_back(v8::Integer::New(client_id)); |
| Line 105... | Line 107... | ||
| 105 | 107 | ||
| 106 | Value Socket::Export_Connect(const v8::Arguments& args) |
108 | Value Socket::Export_Connect(const v8::Arguments& args) |
| 107 | { |
109 | { |
| 108 | v8::Locker lock; |
110 | v8::Locker lock; |
| 109 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
111 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 112 | v8::HandleScope handle_scope; |
|
| 110 | 113 | ||
| 111 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
114 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 112 | 115 | ||
| 113 | if (args.Length() < 2) |
116 | if (args.Length() < 2) |
| 114 | { |
117 | { |
| 115 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
118 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 116 | return v8 |
119 | return handle_scope.Close(v8::Boolean::New(false)); |
| 117 | } |
120 | } |
| 118 | 121 | ||
| 119 | v8::String::AsciiValue address(args[0]); |
122 | v8::String::AsciiValue address(args[0]); |
| 120 | 123 | ||
| 121 | net::ClientId client_id = net::Manager::Instance()->Connect(net::PROTOCOL_TCP, std::string(*address), args[1]->Uint32Value()); |
124 | net::ClientId client_id = net::Manager::Instance()->Connect(net::PROTOCOL_TCP, std::string(*address), args[1]->Uint32Value()); |
| 122 | 125 | ||
| 123 | return v8 |
126 | return handle_scope.Close(v8::Integer::New(client_id)); |
| 124 | } |
127 | } |
| 125 | 128 | ||
| 126 | Value Socket::Export_Disconnect(const v8::Arguments& args) |
129 | Value Socket::Export_Disconnect(const v8::Arguments& args) |
| 127 | { |
130 | { |
| 128 | v8::Locker lock; |
131 | v8::Locker lock; |
| 129 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
132 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 133 | v8::HandleScope handle_scope; |
|
| 130 | 134 | ||
| 131 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
135 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 132 | 136 | ||
| 133 | if (args.Length() < 1) |
137 | if (args.Length() < 1) |
| 134 | { |
138 | { |
| 135 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
139 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 136 | return v8 |
140 | return handle_scope.Close(v8::Boolean::New(false)); |
| 137 | } |
141 | } |
| 138 | 142 | ||
| 139 | net::Manager::Instance()->Disconnect(args[0]->Uint32Value()); |
143 | net::Manager::Instance()->Disconnect(args[0]->Uint32Value()); |
| 140 | 144 | ||
| 141 | return v8: |
145 | return handle_scope.Close(v8::Undefined()); |
| 142 | } |
146 | } |
| 143 | 147 | ||
| 144 | Value Socket::Export_Send(const v8::Arguments& args) |
148 | Value Socket::Export_Send(const v8::Arguments& args) |
| 145 | { |
149 | { |
| 146 | v8::Locker lock; |
150 | v8::Locker lock; |
| 147 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
151 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 152 | v8::HandleScope handle_scope; |
|
| 148 | 153 | ||
| 149 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
154 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 150 | 155 | ||
| 151 | if (args.Length() < 2) |
156 | if (args.Length() < 2) |
| 152 | { |
157 | { |
| 153 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
158 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 154 | return v8 |
159 | return handle_scope.Close(v8::Boolean::New(false)); |
| 155 | } |
160 | } |
| 156 | 161 | ||
| 157 | v8::String::AsciiValue data(args[1]); |
162 | v8::String::AsciiValue data(args[1]); |
| 158 | 163 | ||
| 159 | net::Manager::Instance()->SendTo(args[0]->Uint32Value(), std::string(*data)); |
164 | net::Manager::Instance()->SendTo(args[0]->Uint32Value(), std::string(*data)); |
| 160 | 165 | ||
| 161 | return v8: |
166 | return handle_scope.Close(v8::Undefined()); |
| 162 | } |
167 | } |
| 163 | 168 | ||
| 164 | }; // namespace plugin |
169 | }; // namespace plugin |
| 165 | }; // namespace vm |
170 | }; // namespace vm |
| 166 | }; // namespace atom |
171 | }; // namespace atom |