mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #177 from tekn0ir/fix_libssl_example
Fix linking error on OSX & fix websocket example
This commit is contained in:
commit
6df366ce1d
@ -19,7 +19,13 @@ endif()
|
|||||||
|
|
||||||
add_executable(example_websocket websocket/example_ws.cpp)
|
add_executable(example_websocket websocket/example_ws.cpp)
|
||||||
target_link_libraries(example_websocket ${Boost_LIBRARIES})
|
target_link_libraries(example_websocket ${Boost_LIBRARIES})
|
||||||
target_link_libraries(example_websocket ${CMAKE_THREAD_LIBS_INIT} ssl crypto)
|
target_link_libraries(example_websocket ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES})
|
||||||
|
add_custom_command(OUTPUT ws.html
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E
|
||||||
|
copy ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html ${CMAKE_CURRENT_BINARY_DIR}/ws.html
|
||||||
|
DEPENDS ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html
|
||||||
|
)
|
||||||
|
add_custom_target(example_ws_copy ALL DEPENDS ws.html)
|
||||||
|
|
||||||
add_executable(example example.cpp)
|
add_executable(example example.cpp)
|
||||||
#target_link_libraries(example crow)
|
#target_link_libraries(example crow)
|
||||||
|
@ -33,10 +33,10 @@ int main()
|
|||||||
|
|
||||||
CROW_ROUTE(app, "/")
|
CROW_ROUTE(app, "/")
|
||||||
([]{
|
([]{
|
||||||
char name[256];
|
char name[256];
|
||||||
gethostname(name, 256);
|
gethostname(name, 256);
|
||||||
crow::mustache::context x;
|
crow::mustache::context x;
|
||||||
x["servername"] = name;
|
x["servername"] = name;
|
||||||
|
|
||||||
auto page = crow::mustache::load("ws.html");
|
auto page = crow::mustache::load("ws.html");
|
||||||
return page.render(x);
|
return page.render(x);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
</textarea>
|
</textarea>
|
||||||
<script>
|
<script>
|
||||||
var sock = new WebSocket("ws://{{servername}}:40080/ws");
|
var sock = new WebSocket("ws://{{servername}}:40080/ws");
|
||||||
|
|
||||||
sock.onopen = ()=>{
|
sock.onopen = ()=>{
|
||||||
console.log('open')
|
console.log('open')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user