#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
extern "C" {
#define MONGO_HAVE_STDINT
#include
#include
#include
}
#include "bson.h"
#define DEBUGMODE 0
#define pdebug(...) do{if(DEBUGMODE)printf(__VA_ARGS__);}while(0)
const int chunk_size(4094);
const int headerSize(sizeof(mongo_header) + sizeof(mongo_reply_fields));
using namespace v8;
void setNonBlocking(int sock) {
int sockflags = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, sockflags | O_NONBLOCK);
}
class Connection : public node::EventEmitter {
public:
static void
Initialize (Handle