forked from NodeppOfficial/nodepp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (23 loc) · 677 Bytes
/
Copy pathmain.cpp
File metadata and controls
35 lines (23 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <nodepp/nodepp.h>
#include <nodepp/http.h>
#include <nodepp/ws.h>
using namespace nodepp;
void onMain(){
auto srv = http::server([=]( http_t cli ){
cli.write_header( 200, header_t({}) );
cli.write( "hello world!" );
});
ws::server( srv );
srv.onConnect([=]( ws_t cli ){
cli.onData([=]( string_t data ){
console::log( ">>", data );
cli.close();
});
cli.onClose([=](){
console::log( "disconnected" );
}); console::log( "---connected" );
});
srv.listen( "localhost", 8000, [=]( socket_t ){
console::log( ">> http://localhost:8000" );
});
}