Browse Source

cleanup: rename some of the callbacks

v0.7.4-release
Ryan 16 years ago
parent
commit
13062832d8
  1. 16
      src/net.cc
  2. 17
      src/net.h

16
src/net.cc

@ -94,12 +94,12 @@ Connection::Connection (Handle<Object> handle)
port_ = NULL; port_ = NULL;
oi_socket_init(&socket_, timeout); oi_socket_init(&socket_, timeout);
socket_.on_connect = Connection::_OnConnect; socket_.on_connect = Connection::on_connect;
socket_.on_read = Connection::_OnReceive; socket_.on_read = Connection::on_read;
socket_.on_drain = Connection::_OnDrain; socket_.on_drain = Connection::on_drain;
socket_.on_error = Connection::_OnError; socket_.on_error = Connection::on_error;
socket_.on_close = Connection::_OnDisconnect; socket_.on_close = Connection::on_close;
socket_.on_timeout = Connection::_OnTimeout; socket_.on_timeout = Connection::on_timeout;
socket_.data = this; socket_.data = this;
} }
@ -370,8 +370,8 @@ Acceptor::Acceptor (Handle<Object> handle, Handle<Object> options)
} }
oi_server_init(&server_, backlog); oi_server_init(&server_, backlog);
server_.on_connection = Acceptor::_OnConnection; server_.on_connection = Acceptor::on_connection;
server_.on_error = Acceptor::_OnError; server_.on_error = Acceptor::on_error;
server_.data = this; server_.data = this;
} }

17
src/net.h

@ -53,12 +53,13 @@ protected:
v8::Handle<v8::Object> server); v8::Handle<v8::Object> server);
private: private:
static void _OnConnect (oi_socket *s) { /* liboi callbacks */
static void on_connect (oi_socket *s) {
Connection *connection = static_cast<Connection*> (s->data); Connection *connection = static_cast<Connection*> (s->data);
connection->OnConnect(); connection->OnConnect();
} }
static void _OnReceive (oi_socket *s, const void *buf, size_t len) { static void on_read (oi_socket *s, const void *buf, size_t len) {
Connection *connection = static_cast<Connection*> (s->data); Connection *connection = static_cast<Connection*> (s->data);
if (len == 0) if (len == 0)
connection->OnEOF(); connection->OnEOF();
@ -66,22 +67,22 @@ private:
connection->OnReceive(buf, len); connection->OnReceive(buf, len);
} }
static void _OnDrain (oi_socket *s) { static void on_drain (oi_socket *s) {
Connection *connection = static_cast<Connection*> (s->data); Connection *connection = static_cast<Connection*> (s->data);
connection->OnDrain(); connection->OnDrain();
} }
static void _OnError (oi_socket *s, oi_error e) { static void on_error (oi_socket *s, oi_error e) {
Connection *connection = static_cast<Connection*> (s->data); Connection *connection = static_cast<Connection*> (s->data);
connection->OnError(e); connection->OnError(e);
} }
static void _OnDisconnect (oi_socket *s) { static void on_close (oi_socket *s) {
Connection *connection = static_cast<Connection*> (s->data); Connection *connection = static_cast<Connection*> (s->data);
connection->OnDisconnect(); connection->OnDisconnect();
} }
static void _OnTimeout (oi_socket *s) { static void on_timeout (oi_socket *s) {
Connection *connection = static_cast<Connection*> (s->data); Connection *connection = static_cast<Connection*> (s->data);
connection->OnTimeout(); connection->OnTimeout();
} }
@ -124,7 +125,7 @@ protected:
static v8::Handle<v8::Value> v8Close (const v8::Arguments& args); static v8::Handle<v8::Value> v8Close (const v8::Arguments& args);
private: private:
static oi_socket* _OnConnection (oi_server *s, struct sockaddr *addr, socklen_t len) { static oi_socket* on_connection (oi_server *s, struct sockaddr *addr, socklen_t len) {
Acceptor *acceptor = static_cast<Acceptor*> (s->data); Acceptor *acceptor = static_cast<Acceptor*> (s->data);
Connection *connection = acceptor->OnConnection (addr, len); Connection *connection = acceptor->OnConnection (addr, len);
if (connection) if (connection)
@ -133,7 +134,7 @@ private:
return NULL; return NULL;
} }
static void _OnError (oi_server *s, struct oi_error error) { static void on_error (oi_server *s, struct oi_error error) {
Acceptor *acceptor = static_cast<Acceptor*> (s->data); Acceptor *acceptor = static_cast<Acceptor*> (s->data);
acceptor->OnError (error); acceptor->OnError (error);
} }

Loading…
Cancel
Save