Changeset - 38f907aa6e08
[Not reviewed]
0 1 0
Jan Kaluza - 13 years ago 2012-10-22 15:05:17
hanzz.k@gmail.com
Log mongoose error
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/server.cpp
Show inline comments
 
@@ -140,25 +140,27 @@ static void generate_session_id(char *buf, const char *random,
 
                                const char *user) {
 
  mg_md5(buf, random, user, NULL);
 
}
 

	
 
Server::Server(ManagerConfig *config) {
 
	srand((unsigned) time(0));
 
	m_config = config;
 
	m_user = CONFIG_STRING(m_config, "service.admin_username");
 
	m_password = CONFIG_STRING(m_config, "service.admin_password");
 
}
 

	
 
Server::~Server() {
 
	mg_stop(ctx);
 
	if (ctx) {
 
		mg_stop(ctx);
 
	}
 
}
 

	
 

	
 
static void *_event_handler(enum mg_event event, struct mg_connection *conn) {
 
	const struct mg_request_info *request_info = mg_get_request_info(conn);
 
	return static_cast<Server *>(request_info->user_data)->event_handler(event, conn);
 
}
 

	
 
bool Server::start() {
 
	const char *options[] = {
 
		"listening_ports", boost::lexical_cast<std::string>(CONFIG_INT(m_config, "service.port")).c_str(),
 
		"num_threads", "1",
 
@@ -437,22 +439,27 @@ void *Server::event_handler(enum mg_event event, struct mg_connection *conn) {
 
			serve_onlineusers(conn, request_info);
 
		} else if (strcmp(request_info->uri, "/cmd") == 0) {
 
			serve_cmd(conn, request_info);
 
		} else if (strcmp(request_info->uri, "/start") == 0) {
 
			serve_start(conn, request_info);
 
		} else if (strcmp(request_info->uri, "/stop") == 0) {
 
			serve_stop(conn, request_info);
 
		} else {
 
			// No suitable handler found, mark as not processed. Mongoose will
 
			// try to serve the request.
 
			processed = NULL;
 
		}
 
	} else {
 
	}
 
	else if (event == MG_EVENT_LOG) {
 
		// Called by Mongoose's cry()
 
		std::cerr << "Mongoose error: " << request_info->log_message << "\n";
 
	}
 
	else {
 
		processed = NULL;
 
	}
 

	
 
	return processed;
 
}
 

	
 

	
 

	
 

	
0 comments (0 inline, 0 general)