{"id":51395770,"url":"https://github.com/ntoskrnl7/wsmq-rs","last_synced_at":"2026-07-04T02:06:57.195Z","repository":{"id":48527895,"uuid":"374420945","full_name":"ntoskrnl7/wsmq-rs","owner":"ntoskrnl7","description":"A simple messaging library based on websockets and protocol buffers.","archived":false,"fork":false,"pushed_at":"2021-09-06T13:50:15.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-03T19:58:18.623Z","etag":null,"topics":["easy-to-use","protobuf","rust","snapy","websocket"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntoskrnl7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-06T17:20:31.000Z","updated_at":"2022-07-31T11:02:59.000Z","dependencies_parsed_at":"2022-08-31T12:12:00.004Z","dependency_job_id":null,"html_url":"https://github.com/ntoskrnl7/wsmq-rs","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/ntoskrnl7/wsmq-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fwsmq-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fwsmq-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fwsmq-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fwsmq-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntoskrnl7","download_url":"https://codeload.github.com/ntoskrnl7/wsmq-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntoskrnl7%2Fwsmq-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35107508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["easy-to-use","protobuf","rust","snapy","websocket"],"created_at":"2026-07-04T02:06:56.123Z","updated_at":"2026-07-04T02:06:57.184Z","avatar_url":"https://github.com/ntoskrnl7.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wsmq-rs\n\n[![Rust](https://github.com/ntoskrnl7/wsmq-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/ntoskrnl7/wsmq-rs/actions/workflows/rust.yml)\n\nA simple websocket messaging library based on protocol buffers.\n\n## Example\n\n### Basic\n\n#### Server\n\n```rust\nwsmq::server::run(\"0.0.0.0:8080\", |addr, res, _| {\n    let mut recieved = res.to_vec().clone();\n    tokio::spawn(async move {\n        recieved.extend(\u0026addr.port().to_le_bytes());\n        res.reply(recieved).await;\n    });\n})\n.await\n.unwrap();\n```\n\n#### Client\n\n```rust\nlet client = wsmq::client::connect(\"ws://127.0.0.1:8080\")\n    .await\n    .unwrap();\nclient.send(vec![1, 2, 3, 4, 5]).unwrap();\n\nlet res = client.send(vec![1, 2, 3, 4, 5]).unwrap().await.unwrap();\nlet recieved = res.to_vec();\nprintln!(\"{:?}\", recieved);\n```\n\n---\n\n### With protocol buffers\n\n#### Protocol buffers\n\n```proto\nsyntax = \"proto3\";\n\nmessage RequestMessage {\n    string text = 1;\n}\nmessage ResponseMessage {\n    string text = 1;\n    bytes payload = 2;\n}\n```\n\n#### Server with protocol buffers\n\n```rust\nwsmq::server::run(\"0.0.0.0:8080\", |addr, res, _| {\n    let mut message = res.to_message::\u003cRequestMessage\u003e().expect(\"[server] Failed to to_message\");\n    tokio::spawn(async move {\n        let mut response_message = ResponseMessage::new();\n        response_message.set_text(\"response text\".to_string());\n        response_message.set_payload(message.get_text().as_bytes().to_vec());\n        res.reply_message(\u0026response_message).await;\n    });\n})\n.await\n.expect(\"[server] Failed to run\");\n```\n\n#### Client with protocol buffers\n\n```rust\nlet client = wsmq::client::connect(\"ws://127.0.0.1:8080\")\n    .await\n    .expect(\"[client] Failed to connect\");\n\nlet mut message = RequestMessage::new();\nmessage.set_text(\"request text\".to_string());\n\nlet res = client.send_message(\u0026message)\n    .expect(\"[client] Failed to send_message\");\n    .await\n    .expect(\"[client] Failed to send_message\");\n\nlet message = res.to_message::\u003cResponseMessage\u003e()\n    .expect(\"[client] Failed to to_message\");\n\nprintln!(\"{:?}\", message);\n```\n\n---\n\n### With config\n\n#### Server with config\n\n```rust\nwsmq::server::run_with_config(\n    \"0.0.0.0:8080\",\n    |addr, res, _| {\n        let mut recieved = res.to_vec().clone();\n        tokio::spawn(async move {\n            recieved.extend(\u0026addr.port().to_le_bytes());\n            res.reply(recieved).await;\n        });\n    },\n    wsmq::server::Config::\u003c()\u003e::new().set_bandwidth(1024 * 1024 * 6),\n)\n.await\n.unwrap();\n```\n\n#### Client with config\n\n```rust\nlet client = wsmq::client::connect_with_config(\n    \"ws://127.0.0.1:8080\",\n    wsmq::client::Config::new().set_bandwidth(1024 * 1024 * 6),\n)\n.await\n.unwrap();\nclient.send(vec![1, 2, 3, 4, 5]).unwrap();\n\nlet res = client.send(vec![1, 2, 3, 4, 5]).unwrap().await.unwrap();\nlet recieved = res.to_vec();\nprintln!(\"{:?}\", recieved);\n```\n\n---\n\n### With context\n\n#### Server with context\n\n```rust\n#[derive(Debug)]\nstruct Context {\n    port: u16,\n    sent: usize,\n    recieved: usize,\n}\n\nwsmq::server::run_with_config(\n    \"0.0.0.0:8080\",\n    |addr, res, context| {\n        context.recieved += 1;\n        let mut recieved = res.to_vec().clone();\n        recieved.extend(\u0026addr.port().to_le_bytes());\n        if let Ok(_) = block_on(res.reply(recieved)) {\n            context.sent += 1;\n        }\n    },\n    wsmq::server::Config::new()\n        set_bandwidth(1024),\n        .on_connect(Box::new(|addr| {\n            println!(\"connected ({})\", addr);\n            Context {\n                port: addr.port(),\n                sent: 0,\n                recieved: 0,\n            }\n        }))\n        .on_disconnect(Box::new(|addr, context| {\n            assert_eq!(addr.port(), context.port);\n            println!(\"disconnected({}): {:?}\", addr, context);\n        }))\n        .on_started(Box::new(|| {\n            println!(\"started\");\n        }))\n        .on_error(Box::new(|err, ctx| {\n            if let Some(ctx) = ctx {\n                println!(\"error({:?}) : {}\", ctx, err);\n            } else {\n                println!(\"error : {}\", err);\n            }\n        }))\n        .on_progress(Box::new(|pctx, ctx| {\n            println!(\"progress ({:?}) : {:?}\", ctx, pctx);\n        })),\n)\n.await\n.unwrap();\n```\n\n#### Client with context\n\n```rust\nlet client = wsmq::client::connect_with_config(\n    \"ws://127.0.0.1:8080\",\n    wsmq::client::Config::new().set_bandwidth(1024),\n)\n.await\n.unwrap();\nclient.send(vec![1, 2, 3, 4, 5]).unwrap();\nlet res = client.send(vec![1, 2, 3, 4, 5]).unwrap().await.unwrap();\nlet recieved = res.to_vec();\nprintln!(\"{:?}\", recieved);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntoskrnl7%2Fwsmq-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntoskrnl7%2Fwsmq-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntoskrnl7%2Fwsmq-rs/lists"}