Rev 1898 | Rev 1954 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1898 | Rev 1940 | ||
|---|---|---|---|
| Line 105... | Line 105... | ||
| 105 | this->Call(client_id, "Socket_OnNewState", arguments); |
105 | this->Call(client_id, "Socket_OnNewState", arguments); |
| 106 | } |
106 | } |
| 107 | 107 | ||
| 108 | Value Socket::Export_Connect(const v8::Arguments& args) |
108 | Value Socket::Export_Connect(const v8::Arguments& args) |
| 109 | { |
109 | { |
| - | 110 | net::ClientId client_id = 0; |
|
| 110 | v8::Locker lock; |
111 | v8::Locker lock; |
| 111 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
112 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 112 | v8::HandleScope handle_scope; |
113 | v8::HandleScope handle_scope; |
| 113 | 114 | ||
| 114 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
115 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| Line 119... | Line 120... | ||
| 119 | return handle_scope.Close(v8::Boolean::New(false)); |
120 | return handle_scope.Close(v8::Boolean::New(false)); |
| 120 | } |
121 | } |
| 121 | 122 | ||
| 122 | v8::String::AsciiValue address(args[0]); |
123 | v8::String::AsciiValue address(args[0]); |
| 123 | 124 | ||
| - | 125 | try |
|
| - | 126 | { |
|
| 124 |
|
127 | client_id = net::Manager::Instance()->Connect(net::PROTOCOL_TCP, std::string(*address), args[1]->Uint32Value()); |
| - | 128 | } |
|
| - | 129 | catch (std::runtime_error &e) |
|
| - | 130 | { |
|
| 125 | 131 | } |
|
| - | 132 | ||
| 126 | return handle_scope.Close(v8::Integer::New(client_id)); |
133 | return handle_scope.Close(v8::Integer::New(client_id)); |
| 127 | } |
134 | } |
| 128 | 135 | ||
| 129 | Value Socket::Export_Disconnect(const v8::Arguments& args) |
136 | Value Socket::Export_Disconnect(const v8::Arguments& args) |
| 130 | { |
137 | { |
| 131 | v8::Locker lock; |
138 | v8::Locker lock; |
| 132 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
139 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 133 | v8::HandleScope handle_scope; |
140 | v8::HandleScope handle_scope; |
| 134 | 141 | ||
| 135 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
142 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 136 | - | ||
| 137 | if (args.Length() < 1) |
- | |
| 138 | { |
- | |
| 139 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
- | |
| 140 | return handle_scope.Close(v8::Boolean::New(false)); |
- | |
| 141 | } |
- | |
| 142 | 143 | ||
| - | 144 | if (args.Length() < 1) |
|
| - | 145 | { |
|
| - | 146 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
|
| - | 147 | return handle_scope.Close(v8::Boolean::New(false)); |
|
| - | 148 | } |
|
| - | 149 | ||
| 143 | net::Manager::Instance()->Disconnect(args[0]->Uint32Value()); |
150 | net::Manager::Instance()->Disconnect(args[0]->Uint32Value()); |
| 144 | 151 | ||
| 145 | return handle_scope.Close(v8::Undefined()); |
152 | return handle_scope.Close(v8::Undefined()); |
| 146 | } |
153 | } |
| 147 | 154 | ||
| 148 | Value Socket::Export_Send(const v8::Arguments& args) |
155 | Value Socket::Export_Send(const v8::Arguments& args) |
| 149 | { |
156 | { |
| 150 | v8::Locker lock; |
157 | v8::Locker lock; |
| 151 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
158 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 152 | v8::HandleScope handle_scope; |
159 | v8::HandleScope handle_scope; |
| 153 | 160 | ||
| 154 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
161 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 155 | 162 | ||
| 156 | if (args.Length() < 2) |
163 | if (args.Length() < 2) |
| 157 | { |
164 | { |
| 158 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
165 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 159 | return handle_scope.Close(v8::Boolean::New(false)); |
166 | return handle_scope.Close(v8::Boolean::New(false)); |
| 160 | } |
167 | } |
| 161 | 168 | ||
| 162 | v8::String::AsciiValue data(args[1]); |
169 | v8::String::AsciiValue data(args[1]); |
| 163 | 170 | ||
| 164 | net::Manager::Instance()->SendTo(args[0]->Uint32Value(), std::string(*data)); |
171 | net::Manager::Instance()->SendTo(args[0]->Uint32Value(), std::string(*data)); |
| 165 | 172 | ||
| Line 167... | Line 174... | ||
| 167 | } |
174 | } |
| 168 | 175 | ||
| 169 | }; // namespace plugin |
176 | }; // namespace plugin |
| 170 | }; // namespace vm |
177 | }; // namespace vm |
| 171 | }; // namespace atom |
178 | }; // namespace atom |
| - | 179 | ||