Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yoruakio/websocket-server
📡 WebSocket-Server: Simple websocket server build using websocketpp and asio libraries.
https://github.com/yoruakio/websocket-server
cmake cpp json server websocket websockets websockets-client websockets-server
Last synced: 5 days ago
JSON representation
📡 WebSocket-Server: Simple websocket server build using websocketpp and asio libraries.
- Host: GitHub
- URL: https://github.com/yoruakio/websocket-server
- Owner: YoruAkio
- License: mit
- Created: 2024-10-22T01:26:20.000Z (16 days ago)
- Default Branch: main
- Last Pushed: 2024-10-23T03:29:15.000Z (15 days ago)
- Last Synced: 2024-11-02T02:05:16.370Z (5 days ago)
- Topics: cmake, cpp, json, server, websocket, websockets, websockets-client, websockets-server
- Language: C++
- Homepage:
- Size: 1.28 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebSocket-Demo
Simple websocket server build using websocket and asio libraries.
## Requirements
- CMake 3.25 or higher
- Git
- Compiler ( GCC, Clang, MSVC )
- a bit cells of your brain lmao## Building
```bash
git clone https://github.com/yoruakio/WebSocket-Server.git
cd WebSocket-Server && mkdir build && cd build
cmake ..
cmake --build . && ./WebSocketServer
```## Information
This is client code for the WebSocket-Server. It is a simple websocket client that can be used to demonstrate how to use websockets in C++.
```cpp
typedef websocketpp::client client;std::string uri = "ws://localhost:9002";
std::string auth_token = "your_secret_token"; // Replace with your actual tokenclient c;
c.init_asio();c.set_open_handler([&c](websocketpp::connection_hdl hdl) {
std::cout << "Connection opened" << std::endl;
c.send(hdl, "Hello, Server!", websocketpp::frame::opcode::text);
});
c.set_message_handler([](websocketpp::connection_hdl, client::message_ptr msg) {
std::cout << "Received message: " << msg->get_payload() << std::endl;
});websocketpp::lib::error_code ec;
client::connection_ptr con = c.get_connection(uri, ec);if (ec) {
std::cout << "Could not create connection because: " << ec.message() << std::endl;
return 1;
}con->append_header("Authorization", auth_token);
c.connect(con);
c.run();
```## Contact
If you have any questions or suggestions, feel free to contact me at:
- Discord: [@yoruakio](https://discord.com/users/919841186246692886)
- Telegram: [@yoruakio](https://t.me/yoruakio) or [HTF](https://t.me/htf_public)## LICENSE
WebSocket-Server is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.