first commit
This commit is contained in:
12
third_party/socket.io-client-cpp/lib/websocketpp/examples/print_server/CMakeLists.txt
vendored
Normal file
12
third_party/socket.io-client-cpp/lib/websocketpp/examples/print_server/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
file (GLOB SOURCE_FILES *.cpp)
|
||||
file (GLOB HEADER_FILES *.hpp)
|
||||
|
||||
init_target (print_server)
|
||||
|
||||
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
link_boost ()
|
||||
final_target ()
|
||||
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
|
||||
23
third_party/socket.io-client-cpp/lib/websocketpp/examples/print_server/SConscript
vendored
Normal file
23
third_party/socket.io-client-cpp/lib/websocketpp/examples/print_server/SConscript
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
## Print server example
|
||||
##
|
||||
|
||||
Import('env')
|
||||
Import('env_cpp11')
|
||||
Import('boostlibs')
|
||||
Import('platform_libs')
|
||||
Import('polyfill_libs')
|
||||
|
||||
env = env.Clone ()
|
||||
env_cpp11 = env_cpp11.Clone ()
|
||||
|
||||
prgs = []
|
||||
|
||||
# if a C++11 environment is available build using that, otherwise use boost
|
||||
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
|
||||
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
|
||||
prgs += env_cpp11.Program('print_server', ["print_server.cpp"], LIBS = ALL_LIBS)
|
||||
else:
|
||||
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
|
||||
prgs += env.Program('print_server', ["print_server.cpp"], LIBS = ALL_LIBS)
|
||||
|
||||
Return('prgs')
|
||||
24
third_party/socket.io-client-cpp/lib/websocketpp/examples/print_server/print_server.cpp
vendored
Normal file
24
third_party/socket.io-client-cpp/lib/websocketpp/examples/print_server/print_server.cpp
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <websocketpp/config/asio_no_tls.hpp>
|
||||
#include <websocketpp/server.hpp>
|
||||
|
||||
typedef websocketpp::server<websocketpp::config::asio> server;
|
||||
|
||||
void on_message(websocketpp::connection_hdl, server::message_ptr msg) {
|
||||
std::cout << msg->get_payload() << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
server print_server;
|
||||
|
||||
print_server.set_message_handler(&on_message);
|
||||
print_server.set_access_channels(websocketpp::log::alevel::all);
|
||||
print_server.set_error_channels(websocketpp::log::elevel::all);
|
||||
|
||||
print_server.init_asio();
|
||||
print_server.listen(9002);
|
||||
print_server.start_accept();
|
||||
|
||||
print_server.run();
|
||||
}
|
||||
Reference in New Issue
Block a user