Permalink
Browse files

Inspector

  • Loading branch information...
chenshuo committed May 7, 2010
1 parent 563d6bd commit a32e2f38cdffaab880b91433136f4a355584c896
View
@@ -0,0 +1 @@
+*.swp
@@ -12,6 +12,7 @@
#define MUDUO_NET_HTTP_HTTPSERVER_H
#include <muduo/net/TcpServer.h>
+#include <boost/noncopyable.hpp>
namespace muduo
{
@@ -3,6 +3,8 @@ set(inspect_SRCS
)
add_library(muduo_inspect ${inspect_SRCS})
-target_link_libraries(muduo_inspect muduo_net)
+target_link_libraries(muduo_inspect muduo_http)
+
+add_executable(inspector_test tests/Inspector_test.cc)
+target_link_libraries(inspector_test muduo_inspect)
-# add_subdirectory(tests)
@@ -8,8 +8,22 @@
//
#include <muduo/net/inspect/Inspector.h>
+#include <muduo/net/EventLoop.h>
+
+#include <boost/bind.hpp>
using namespace muduo;
using namespace muduo::net;
+Inspector::Inspector(EventLoop* loop,
+ const InetAddress& httpAddr,
+ const string& name)
+ : server_(loop, httpAddr, "Inspector:"+name)
+{
+ loop->runAfter(0, boost::bind(&Inspector::start, this));
+}
+void Inspector::start()
+{
+ server_.start();
+}
@@ -11,18 +11,26 @@
#ifndef MUDUO_NET_INSPECT_INSPECTOR_H
#define MUDUO_NET_INSPECT_INSPECTOR_H
+#include <muduo/net/http/HttpServer.h>
#include <boost/noncopyable.hpp>
namespace muduo
{
namespace net
{
+// A internal inspector of the running process, usually a singleton.
class Inspector : boost::noncopyable
{
public:
+ Inspector(EventLoop* loop,
+ const InetAddress& httpAddr,
+ const string& name);
private:
+ void start();
+
+ HttpServer server_;
};
}
@@ -0,0 +1,13 @@
+#include <muduo/net/inspect/Inspector.h>
+#include <muduo/net/EventLoop.h>
+
+using namespace muduo;
+using namespace muduo::net;
+
+int main()
+{
+ EventLoop loop;
+ Inspector ins(&loop, InetAddress(12345), "test");
+ loop.loop();
+}
+

0 comments on commit a32e2f3

Please sign in to comment.