Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rerun-io/ewebsock
A Rust Websocket client that compiles to both native and web
https://github.com/rerun-io/ewebsock
rust websocket
Last synced: 7 days ago
JSON representation
A Rust Websocket client that compiles to both native and web
- Host: GitHub
- URL: https://github.com/rerun-io/ewebsock
- Owner: rerun-io
- License: apache-2.0
- Created: 2022-02-23T10:41:54.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T15:42:52.000Z (3 months ago)
- Last Synced: 2025-01-17T20:03:26.960Z (14 days ago)
- Topics: rust, websocket
- Language: Rust
- Homepage:
- Size: 4.1 MB
- Stars: 237
- Watchers: 2
- Forks: 29
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ewebsock
[](https://github.com/rerun-io/ewebsock)
[![Latest version](https://img.shields.io/crates/v/ewebsock.svg)](https://crates.io/crates/ewebsock)
[![Documentation](https://docs.rs/ewebsock/badge.svg)](https://docs.rs/ewebsock)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
[![Build Status](https://github.com/rerun-io/ewebsock/workflows/CI/badge.svg)](https://github.com/rerun-io/ewebsock/actions?workflow=CI)
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)This is a simple [WebSocket](https://en.wikipedia.org/wiki/WebSocket) library for Rust which can be compiled to both native and web (WASM).
## Usage
``` rust
let options = ewebsock::Options::default();
// see documentation for more options
let (mut sender, receiver) = ewebsock::connect("ws://example.com", options).unwrap();
sender.send(ewebsock::WsMessage::Text("Hello!".into()));
while let Some(event) = receiver.try_recv() {
println!("Received {:?}", event);
}
```## Testing
First start the example echo server with:
```sh
cargo r -p echo_server
```Then test the library with:
```sh
# native mode
cargo run -p example_app# web mode
# install trunk with `cargo install trunk` - https://trunkrs.dev/
(cd example_app && trunk serve)
```