@@ -112,20 +112,48 @@ Validation rules:
112112
113113``` cpp
114114#include < vix.hpp>
115+ #include < vix/console.hpp>
116+ #include < vix/p2p/Node.hpp>
117+ #include < vix/p2p/P2P.hpp>
115118#include < vix/p2p_http/P2PHttp.hpp>
116119
120+ using namespace vix ;
121+
117122int main ()
118123{
119- vix::App app;
124+ App app;
125+
126+ vix::p2p::NodeConfig cfg;
127+ cfg.node_id = "A";
128+ cfg.listen_port = 9001;
129+
130+ auto node = vix::p2p::make_tcp_node(cfg);
131+ vix::p2p::P2PRuntime runtime(node);
132+ runtime.start();
120133
121- P2PHttpOptions opt;
134+ vix::p2p_http::P2PHttpOptions opt;
135+ opt.prefix = "/api/p2p";
136+ opt.enable_ping = true;
137+ opt.enable_status = true;
122138 opt.enable_peers = true;
139+ opt.enable_logs = true;
140+ opt.enable_live_logs = true;
141+ opt.stats_every_ms = 250;
142+
143+ vix::p2p_http::registerRoutes (app, runtime, opt);
144+
145+ app.static_dir("./public");
146+ app.get("/", [ ] (Request &, Response &res)
147+ { res.file("./public/index.html"); });
148+
149+ app.get("/connect", [ ] (Request &, Response &res)
150+ { res.file("./public/connect.html"); });
123151
124- app.listen(5178, [ ] (const vix::utils::ServerReadyInfo &info){
125- console.info("UI API listening on", info.port);
126- });
152+ app.listen(5178, [ ] (const vix::utils::ServerReadyInfo &info)
153+ { console.info("UI API listening on", info.port); });
127154
128155 app.wait();
156+ runtime.stop();
129157}
130158```
131159
0 commit comments