#websocket #tokio

basws

A simple async WebSocket client/server framework

12 releases

0.1.4 Feb 8, 2021
0.1.3 Feb 5, 2021
0.1.1 Jan 30, 2021
0.1.0-dev-8 Oct 20, 2020
0.1.0-dev-6 Sep 30, 2020

#21 in WebSocket

Download history 3/week @ 2022-03-04 29/week @ 2022-03-11 51/week @ 2022-03-18 6/week @ 2022-03-25 5/week @ 2022-04-01 1/week @ 2022-04-08 2/week @ 2022-04-15 12/week @ 2022-04-22 27/week @ 2022-04-29 72/week @ 2022-05-06 205/week @ 2022-05-13 37/week @ 2022-05-20 73/week @ 2022-05-27 97/week @ 2022-06-03 2/week @ 2022-06-17

172 downloads per month

MIT license

47KB
665 lines

basws

crate version

basws is a simple framework that aims to simplify the amount of code required to build an interactive WebSocket API.

basws is built atop warp on the server, and tokio-tungstenite on the client. Both crates utilize the tokio runtime.

Features

  • Built atop cbor, which has many implementations in various technology stacks
  • Basic support for one account logging in on multiple devices
  • Easy out-of-band async message sending
  • Provides network timing statistics on both the server and client

For a simple example, check out chat example in the ./basws/examples directory.

Usage

Environment

Server

Add either of these lines to your Cargo.toml:

# Either use the basws parent crate
basws = { version = "0.1", features = ["server"] }
# Or, use the basws-server crate
basws-server = "0.1"

Client

Add either of these lines to your Cargo.toml:

# Either use the basws parent crate
basws = { version = "0.1", features = ["client"] }
# Or, use the basws-client crate
basws-client = "0.1"

Yew

Add either of these lines to your Cargo.toml:

# Either use the basws parent crate
basws = { version = "0.1", features = ["yew"] }
# Or, use the basws-client crate
basws-yew = "0.1"

When building for release, an environment variable needs to be present: BASWS_CLIENT_ENCRYPTION_KEY. This should be a 32-character string. It is used to encrypt the session information stored in the browser. If you ever suspect that you need to invalidate existing session information, rotating this key will cause every user to start a new session.

Dependencies

~2–11MB
~199K SLoC