/[projects]/smsdaemon/embedded-http/embeddedhttp.cpp
ViewVC logotype

Diff of /smsdaemon/embedded-http/embeddedhttp.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 679 by torben, Tue Apr 27 21:12:11 2010 UTC revision 680 by torben, Wed Apr 28 07:38:39 2010 UTC
# Line 7  Line 7 
7  #include "Logger.h"  #include "Logger.h"
8  #include "version.h"  #include "version.h"
9  #include "Common.h"  #include "Common.h"
10    #include "ConfigFile.h"
11  #include <sstream>  #include <sstream>
12    #include <stdlib.h>
13    
14  void show_secret(struct mg_connection *conn, const struct mg_request_info *request_info, void *user_data) {  void show_secret(struct mg_connection *conn, const struct mg_request_info *request_info, void *user_data) {
15          Common* cmn = Common::instance();          Common* cmn = Common::instance();
# Line 45  void show_index(struct mg_connection *co Line 46  void show_index(struct mg_connection *co
46  }  }
47    
48  void EmbeddedHttp::startServer() {  void EmbeddedHttp::startServer() {
49          Logger::logMessage("Starting mongoose embedded http engine");          std::string portStr = Common::instance()->GetConfigfile()->GetValue("smsdaemon", "httpport");
50            int port = atoi( portStr.c_str() );
         m_context = mg_start();  
         mg_set_option(m_context, "ports", "8080");  
         mg_set_uri_callback(m_context, "/", &show_index, 0);  
         mg_set_uri_callback(m_context, "/status", &show_secret, 0);  
51    
52            if (port > 0) {
53                    std::ostringstream oss;
54                    oss << "Starting mongoose embedded http engine (listenin on port " << port << ")";
55                    Logger::logMessage( oss.str() );
56    
57                    oss.str(""); //empty string stream
58                    oss << port;
59    
60                    m_context = mg_start();
61                    mg_set_option(m_context, "ports", oss.str().c_str() );
62                    mg_set_uri_callback(m_context, "/", &show_index, 0);
63                    mg_set_uri_callback(m_context, "/status", &show_secret, 0);
64            } else {
65                    Logger::logMessage( "Mongoose http disabled" );
66                    m_context = 0;
67            }
68  }  }
69    
70    
71  void EmbeddedHttp::stopServer() {  void EmbeddedHttp::stopServer() {
72          mg_stop(m_context);          if (m_context != 0) {
73                    mg_stop(m_context);
74            }
75  }  }

Legend:
Removed from v.679  
changed lines
  Added in v.680

  ViewVC Help
Powered by ViewVC 1.1.20