Skip to content

Commit

Permalink
feat: create websocket crate for wasm and native
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Jan 22, 2024
1 parent ee3abdb commit 24844d0
Show file tree
Hide file tree
Showing 8 changed files with 1,224 additions and 1 deletion.
41 changes: 41 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ members = [
"libs/app_error",
"libs/workspace-template",
"libs/encrypt",
"libs/realtime-protocol"
"libs/realtime-protocol",
"libs/websocket",
]

[workspace.dependencies]
Expand Down
55 changes: 55 additions & 0 deletions libs/websocket/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "websocket"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
native-tls = ["tokio-tungstenite/native-tls"]
native-tls-vendored = ["native-tls", "tokio-tungstenite/native-tls-vendored"]
rustls-tls-native-roots = [
"__rustls-tls",
"tokio-tungstenite/rustls-tls-native-roots",
]
rustls-tls-webpki-roots = [
"__rustls-tls",
"tokio-tungstenite/rustls-tls-webpki-roots",
]
__rustls-tls = []

[dependencies]
thiserror = "1"
http = "0.2"
httparse = "1.3"
futures-util = { version = "0.3", default-features = false, features = [
"sink",
"std",
] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio-tungstenite = "0.20"
tokio = { version = "1", default-features = false, features = ["net"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
js-sys = "0.3"
futures-channel = { version = "0.3" }

[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
version = "0.3"
features = [
"WebSocket",
"MessageEvent",
"CloseEvent",
"Event",
"ErrorEvent",
"BinaryType",
"Blob",
]

[dev-dependencies]
assert-impl = "0.1"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tokio = { version = "1", features = ["full"] }
rand = "0.8"
Loading

0 comments on commit 24844d0

Please sign in to comment.