Wexus2 0.20
wexus2.src/wexus/MongooseServer.h
00001 
00002 /*
00003  * Copyright (c) 2011 Aleksander B. Demko
00004  * This source code is distributed under the MIT license.
00005  * See the accompanying file LICENSE.MIT.txt for details.
00006  */
00007 
00008 #ifndef __INCLUDED_WEXUS_MONGOOSESERVER_H__
00009 #define __INCLUDED_WEXUS_MONGOOSESERVER_H__
00010 
00011 #include <wexus/HTTPServer.h>
00012 
00013 #include <stddef.h>   // so size_t is available for mongoose.h
00014 #include "mongoose.h"
00015 
00016 namespace wexus
00017 {
00018   class MongooseServer;
00019 }
00020 
00021 /**
00022  * A mongoose based wexus::HTTPServer implementation.
00023  *
00024  * @author Aleksander Demko
00025  */ 
00026 class wexus::MongooseServer : public wexus::HTTPServer
00027 {
00028   public:
00029     /**
00030      * Creates a new web server. This doesn't actually start it thougth,
00031      * start() does that.
00032      *
00033      * @author Aleksander Demko
00034      */ 
00035     MongooseServer(const wexus::HTTPParams &opt);
00036     /**
00037      * Destructor. If the server is running, this will also call
00038      * quit() and then wait()
00039      *
00040      * @author Aleksander Demko
00041      */ 
00042     virtual ~MongooseServer(void);
00043 
00044     /// is the web server currently running?
00045     virtual bool isRunning(void) const;
00046     /// starts the web server
00047     virtual void start(void);
00048     /// notifies the web server to stop. you should still do a wait()
00049     /// this function may or may not block
00050     virtual void quit(void);
00051     /// waits until the server finishes
00052     virtual void wait(void);
00053 
00054   private:
00055     static void *callback(enum mg_event event, struct mg_connection *conn,
00056         const struct mg_request_info *request_info);
00057 
00058   private:
00059     wexus::HTTPParams dm_opt;
00060     mg_context *dm_ctx;
00061 };
00062 
00063 #endif
00064 
 All Classes Namespaces Functions Variables Enumerations Enumerator