{"id":17928823,"url":"https://github.com/young-flash/websockets-demo","last_synced_at":"2025-04-03T11:14:00.071Z","repository":{"id":157069014,"uuid":"474631350","full_name":"Young-Flash/websockets-demo","owner":"Young-Flash","description":"This is a demo about how to use uWebsockets to implement a server which supports publish and subscribe over websockets protocol (with ssl).","archived":false,"fork":false,"pushed_at":"2022-04-04T08:50:20.000Z","size":115,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T00:28:53.431Z","etag":null,"topics":["cpp","publish-subscribe","websocket","websockets-server"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Young-Flash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-27T12:30:07.000Z","updated_at":"2024-07-31T02:39:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"367722b0-b094-44c9-b574-c8ea9ef331d8","html_url":"https://github.com/Young-Flash/websockets-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Young-Flash%2Fwebsockets-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Young-Flash%2Fwebsockets-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Young-Flash%2Fwebsockets-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Young-Flash%2Fwebsockets-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Young-Flash","download_url":"https://codeload.github.com/Young-Flash/websockets-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246989750,"owners_count":20865331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","publish-subscribe","websocket","websockets-server"],"created_at":"2024-10-28T21:05:28.550Z","updated_at":"2025-04-03T11:14:00.045Z","avatar_url":"https://github.com/Young-Flash.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nThis is a demo about how to use [uWebsockets](https://github.com/uNetworking/uWebSockets) to implement a server which supports publish and subscribe over websockets protocol (with ssl).\n\nThere are two threads, the main thread listen on  `ip:port` to wait websockets client to connect and subscribe some \n`topic` which indicated in the message it sent to server, another thread (`publishTopicRandomly`) simulate topic publish, if a topic which have been subscribed by a specific client published, the message related to this topic will be sent to the corresponding client. mutex and condition_variable are used to synchronize the two threads, thread `publishTopicRandomly` publish topic randomly after there are some clients subscribe.\n\n# Setup\n\nYou must make [uWebsockets](https://github.com/uNetworking/uWebSockets) and its dependency(uSockets, openssl, zlib, \netc) ready in your dev machine. Noted that wss (websockets with ssl) are used here so you have to compile \nuWebsockets with ssl option (`WITH_OPENSSL=1 make`). You can take a look at my [blog](https://flash-flash.gitee.io/2022/03/27/uWebsockets%20%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85/) if you have problem on compiling and \ninstall uWebsockets and uSockets.\n\n# Build\n\nThis demo can build with CMake easily\n\n`git clone https://github.com/Young-Flash/websockets-demo.git `\n\n`cd websocket-demo`\n\n`mkdir build \u0026\u0026 cd build`\n\n`cmake ..`\n\n`make`\n\n`./websocket-demo`\n\n# Run\n\nYou can use Postman as client to access the websockets server\n\n| ![postman-client-0](./misc/postman-client-0.png)  | ![postman-client-1](./misc/postman-client-1.png)   |\n|---------------------------------------------------|----------------------------------------------------|","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoung-flash%2Fwebsockets-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoung-flash%2Fwebsockets-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoung-flash%2Fwebsockets-demo/lists"}