Browse Source

Some fixes to allow HTTPServer to begin listening.

Just tested it and it is accepting connections and parsing! Will add units
soon.
v0.7.4-release
Ryan 16 years ago
parent
commit
2e5b85a13b
  1. 9
      src/http.cc
  2. 4
      src/http.h
  3. 11
      src/net.cc
  4. 2
      src/node.cc

9
src/http.cc

@ -78,13 +78,13 @@ HTTPConnection::Initialize (Handle<Object> target)
{
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(HTTPConnection::v8NewClient);
Local<FunctionTemplate> t = FunctionTemplate::New(v8NewClient);
client_constructor_template = Persistent<FunctionTemplate>::New(t);
client_constructor_template->Inherit(Connection::constructor_template);
client_constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
target->Set(String::NewSymbol("HTTPClient"), client_constructor_template->GetFunction());
t = FunctionTemplate::New(HTTPConnection::v8NewServer);
t = FunctionTemplate::New(v8NewServer);
server_constructor_template = Persistent<FunctionTemplate>::New(t);
server_constructor_template->Inherit(Connection::constructor_template);
server_constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
@ -298,9 +298,8 @@ HTTPServer::Initialize (Handle<Object> target)
{
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(HTTPServer::v8New);
Local<FunctionTemplate> t = FunctionTemplate::New(v8New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->Inherit(Acceptor::constructor_template);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
target->Set(String::NewSymbol("HTTPServer"), constructor_template->GetFunction());
@ -323,7 +322,7 @@ HTTPServer::v8New (const Arguments& args)
options = Object::New();
}
new HTTPServer(args.Holder(), protocol_class, options);
new HTTPServer(args.This(), protocol_class, options);
return args.This();
}

4
src/http.h

@ -43,15 +43,15 @@ protected:
class HTTPServer : public Acceptor {
public:
static void Initialize (v8::Handle<v8::Object> target);
static v8::Persistent<v8::FunctionTemplate> constructor_template;
protected:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
static v8::Handle<v8::Value> v8New (const v8::Arguments& args);
HTTPServer (v8::Handle<v8::Object> handle,
v8::Handle<v8::Function> protocol_class,
v8::Handle<v8::Object> options)
:Acceptor(handle, protocol_class, options) {};
: Acceptor(handle, protocol_class, options) {}
Connection* OnConnection (struct sockaddr *addr, socklen_t len);
};

11
src/net.cc

@ -342,13 +342,14 @@ Acceptor::Initialize (Handle<Object> target)
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(v8New);
t->InstanceTemplate()->SetInternalFieldCount(1);
target->Set(String::NewSymbol("TCPServer"), t->GetFunction());
constructor_template = Persistent<FunctionTemplate>::New(t);
NODE_SET_METHOD(t->InstanceTemplate(), "listen", v8Listen);
NODE_SET_METHOD(t->InstanceTemplate(), "close", v8Close);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template = Persistent<FunctionTemplate>::New(t);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "listen", v8Listen);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "close", v8Close);
target->Set(String::NewSymbol("TCPServer"), constructor_template->GetFunction());
}
Acceptor::Acceptor (Handle<Object> handle, Handle<Function> protocol_class, Handle<Object> options)

2
src/node.cc

@ -251,8 +251,8 @@ main (int argc, char *argv[])
Acceptor::Initialize(g);
Connection::Initialize(g);
HTTPConnection::Initialize(g);
HTTPServer::Initialize(g);
HTTPConnection::Initialize(g);
// NATIVE JAVASCRIPT MODULES
TryCatch try_catch;

Loading…
Cancel
Save