diff --git a/README.md b/README.md index 09d62013..519525af 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ communication channels over a single TCP connection. *IXWebSocket* is a C++ libr * macOS * iOS * Linux -* Android +* Android ## Examples @@ -63,10 +63,11 @@ Here is what the server API looks like. Note that server support is very recent ix::WebSocketServer server(port); server.setOnConnectionCallback( - [&server](std::shared_ptr webSocket) + [&server](std::shared_ptr webSocket, + std::shared_ptr connectionState) { webSocket->setOnMessageCallback( - [webSocket, &server](ix::WebSocketMessageType messageType, + [webSocket, connectionState, &server](ix::WebSocketMessageType messageType, const std::string& str, size_t wireSize, const ix::WebSocketErrorInfo& error, @@ -77,6 +78,12 @@ server.setOnConnectionCallback( { std::cerr << "New connection" << std::endl; + // A connection state object is available, and has a default id + // You can subclass ConnectionState and pass an alternate factory + // to override it. It is useful if you want to store custom + // attributes per connection (authenticated bool flag, attributes, etc...) + std::cerr << "id: " << connectionState->getId() << std::endl; + // The uri the client did connect to. std::cerr << "Uri: " << openInfo.uri << std::endl; @@ -223,13 +230,13 @@ Here is a simplistic diagram which explains how the code is structured in term o +-----------------------+ --- Public | | Start the receiving Background thread. Auto reconnection. Simple websocket Ping. | IXWebSocket | Interface used by C++ test clients. No IX dependencies. -| | +| | +-----------------------+ | | | IXWebSocketServer | Run a server and give each connections its own WebSocket object. | | Each connection is handled in a new OS thread. | | -+-----------------------+ --- Private ++-----------------------+ --- Private | | | IXWebSocketTransport | Low level websocket code, framing, managing raw socket. Adapted from easywsclient. | | diff --git a/third_party/remote_trailing_whitespaces.sh b/third_party/remote_trailing_whitespaces.sh index 7255d50a..14127299 100644 --- a/third_party/remote_trailing_whitespaces.sh +++ b/third_party/remote_trailing_whitespaces.sh @@ -1,2 +1,3 @@ find . -type f -name '*.cpp' -exec sed -i '' 's/[[:space:]]*$//' {} \+ find . -type f -name '*.h' -exec sed -i '' 's/[[:space:]]*$//' {} \+ +find . -type f -name '*.md' -exec sed -i '' 's/[[:space:]]*$//' {} \+ diff --git a/ws/README.md b/ws/README.md index bb1395e1..909e1438 100644 --- a/ws/README.md +++ b/ws/README.md @@ -29,7 +29,7 @@ Subcommands: ws transfer # running on port 8080. # Start receiver first -ws receive ws://localhost:8080 +ws receive ws://localhost:8080 # Then send a file. File will be received and written to disk by the receiver process ws send ws://localhost:8080 /file/to/path