workflow-websocket

Part of the workflow-rs application framework.


github crates.io docs.rs license

Platform-neutral WebSocket Client and native Server.

Features

This crate allows you to develop a WebSocket client that will work uniformly in in hte native environment and in-browser.

Workflow-WebSocket crate is currently (as of Q3 2022) one of the few available async Rust client-side in-browser WebSocket implementations.

This web socket crate offers an async message send API as well as provides access to Receiver and Sender asyncstd channels ([asyncchannel])(https://docs.rs/async-channel/latest/async_channel/) that can be used to send and receive WebSocket messages asynchronously.

NOTE: to use workflow-websocket in the Node.js environment, you need to introduce a W3C WebSocket object before loading the WASM32 library. You can use any Node.js module that exposes a W3C-compatible WebSocket implementation. Two of such modules are WebSocket (provides a custom implementation) and isomorphic-ws (built on top of the ws WebSocket module).

You can use the following shims: // WebSocket globalThis.WebSocket = require('websocket').w3cwebsocket; // isomorphic-ws globalThis.WebSocket = require('isomorphic-ws');