{"id":21043112,"url":"https://github.com/mrinalxdev/websocket-rs","last_synced_at":"2025-03-13T21:44:03.746Z","repository":{"id":237562421,"uuid":"794752556","full_name":"mrinalxdev/websocket-rs","owner":"mrinalxdev","description":"Websocket initials in Rust language","archived":false,"fork":false,"pushed_at":"2024-05-01T22:32:49.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T17:21:53.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/mrinalxdev.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":"2024-05-01T21:56:16.000Z","updated_at":"2024-05-01T22:44:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"2fa359d1-cfbd-4864-ab1c-cda41187635d","html_url":"https://github.com/mrinalxdev/websocket-rs","commit_stats":null,"previous_names":["mrinalxdev/websocket-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fwebsocket-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fwebsocket-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fwebsocket-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fwebsocket-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrinalxdev","download_url":"https://codeload.github.com/mrinalxdev/websocket-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489812,"owners_count":20298997,"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":[],"created_at":"2024-11-19T14:11:01.020Z","updated_at":"2025-03-13T21:44:03.717Z","avatar_url":"https://github.com/mrinalxdev.png","language":"Rust","readme":"# websocket-rs\n\nWebsocket initials in Rust language\n\n### main.rs Documentation for learning\n\nThere is the websocket service stored in the url variable.\n\n- To connect to the service asynchronusly we are using (connect_async) method.\n\n\u003e Connecting to the server .\n\n- There will be lot of errors regarding the async functions used,\n  - First mark the main function under tokio `#[tokio::main]` by doing like this above the main function.\n  - `connect_async` is method under tokio-tungstenite, so import from that.\n\n\u003e Sending and recieving messages\n\n- To send and recieve messages from the service agent, we need to split up the websocket stream into a write and read stream.\n- `.split()` method is used for spliting the stream into multiple stream. Let's take two varaibles known (write)[For writing] and (read)[for reading]\n\n- For writing messages to the stream\n  - (write) ``write.send(msg);`` is used, this is method used from ``futures_util::sink::SinkExt`` crate in rust.\n  - ``let msg = Message::Text()`` is used for declaring the message\n  - At last its an async function so do add ``write.send(msg).await`` at the end.\n\n- For reading messages to the stream\n - You can first check if there is any message by putting it in a if stattement, --\u003e ``read.next()`` to pull out the messages\n - If there is any than print the messages.\n\n # Your Websocket is ready !! 🥳🥳🥳\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fwebsocket-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrinalxdev%2Fwebsocket-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fwebsocket-rs/lists"}