public Mongoose(string document_root, string listening_ports, MongooseBeginRequest request_handler) { version_ = mg_version(); string[] options = { "document_root", document_root, "listening_ports", listening_ports, null }; MongooseBeginRequest_native begin_request_cb = delegate(IntPtr conn) { return request_handler(new MongooseConnection(conn, this)); }; MongooseCallbacks callbacks = new MongooseCallbacks(); callbacks.begin_request = begin_request_cb; // Prevent garbage collection delegates += begin_request_cb; ctx_ = mg_start(options, ref callbacks, IntPtr.Zero); }
private static extern IntPtr mg_start([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPTStr)] string[] options, ref MongooseCallbacks callbacks, IntPtr user_data);