Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: implement EngineIO V3 (closes #22) #24

Merged
merged 45 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8058405
Create CODE_OF_CONDUCT.md
Totodore Jun 17, 2023
0a5a393
Feature: implement EngineIO V3 counting of characters
sleeyax Jun 18, 2023
9024f40
Feat: determine protocol version from URL query
sleeyax Jun 18, 2023
3841cc2
Refactor: use position method to find index
sleeyax Jun 18, 2023
a116a85
Refactor: improve check for V3 binary packet
sleeyax Jun 18, 2023
bccd62e
Feat: add missing character counter
sleeyax Jun 18, 2023
eaab5e4
Feat: implement reverse ping/pong for V3
sleeyax Jun 25, 2023
51da550
Merge remote-tracking branch 'upstream/main' into ft-engineio-v3-support
sleeyax Jun 25, 2023
a26e73a
Fix: implement missing paused polling transport
sleeyax Jun 26, 2023
3b502f4
Fix: don't wrap piped packet in character counter
sleeyax Jun 26, 2023
e5e1db6
Fix: prefix character counter to single packet
sleeyax Jun 28, 2023
711811f
Refactor: move payload parsing to separate file
sleeyax Jun 28, 2023
9e2645a
Fix: close session on invalid packet
sleeyax Jun 28, 2023
2c3feb4
Feat: add v3 protocol ping/pong timeout
sleeyax Jun 29, 2023
7738b41
Refactor: remove unused TryFrom implementation
sleeyax Jul 1, 2023
a88a0b0
Feat: enable protocol versions through features
sleeyax Jul 1, 2023
73c3e1d
Refactor: eliminate more unused code based on protocol version
sleeyax Jul 1, 2023
d62cff2
Feat: add special packet type for v3 binary data
sleeyax Jul 1, 2023
c59bdd5
Fix: remove overkill compile time checks
sleeyax Jul 1, 2023
8df81f4
Test: add engineio V3 test to CI
sleeyax Jul 1, 2023
d4bfefc
Refactor: add clippy suggestions
sleeyax Jul 1, 2023
3c07000
Refactor: move protocol enum to service mod
sleeyax Jul 2, 2023
c2cc664
Refactor: derrive clone on protocol enum
sleeyax Jul 2, 2023
9cedee5
Refactor: remove unnecessary clone on msg
sleeyax Jul 2, 2023
2270748
Refactor: add comments
sleeyax Jul 2, 2023
62ab7b4
Refactor: remove unneeded cfg_if statements
sleeyax Jul 2, 2023
59cf42b
Refactor: return proper error types
sleeyax Jul 2, 2023
79c6f41
Fix: fix duplicate definitions error
sleeyax Jul 2, 2023
b6d689d
Refactor: optimize buffer consumption
sleeyax Jul 2, 2023
72d368f
Refactor: rewrite to remove `unused_mut` override
sleeyax Jul 2, 2023
104b82f
Test: check protocol version in unit tests
sleeyax Jul 2, 2023
811a780
Chore: upate engineio CI config
sleeyax Jul 2, 2023
2b430c9
Refactor: improve binary packet matching
sleeyax Jul 2, 2023
5d19239
Refactor: simplify error mapping
sleeyax Jul 2, 2023
d3bdd83
Refactor: combine packet matching
sleeyax Jul 2, 2023
857c0a5
Refactor: simplify v3 payload parsing
sleeyax Jul 2, 2023
711e8e3
Refactor: rename pong rx,tx to heartbeat rx,tx
sleeyax Jul 2, 2023
7eee19a
Fix:
sleeyax Jul 2, 2023
728891d
Fix: rename remainging pong rx,tx references
sleeyax Jul 2, 2023
e052123
Refactor: move protcol validation to FromStr implementation
sleeyax Jul 2, 2023
38483b7
Refactor: parse length to str rarher than String
sleeyax Jul 2, 2023
a19176e
Refactor: remove unneeded cfg-if dependency
sleeyax Jul 2, 2023
a9c3fb6
Chore: Add TODO comments for future improvements
sleeyax Jul 2, 2023
0e60ced
Chore: apply code formatting
sleeyax Jul 2, 2023
8c8a4a4
Merge branch 'main' into ft-engineio-v3-support
Totodore Jul 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/engineio-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

name: EngineIO CI

on:
push:
tags:
- v*
pull_request:
branches:
- main
- develop

jobs:
e2e_v3:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/checkout@v3
with:
# TODO: replace with official repo once https://github.com/socketio/engine.io-protocol/pull/45 has been merged
repository: sleeyax/engine.io-protocol
path: engine.io-protocol
ref: v3-testsuite
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install deps & run tests
run: |
cd engine.io-protocol/test-suite && npm install && cd ../..
cargo run --bin engineioxide-e2e --release --features v3 --no-default-features > v3_server.txt & npm --prefix engine.io-protocol/test-suite test > v3_client.txt
- name: Server output
if: always()
run: cat v3_server.txt
- name: Client output
if: always()
run: cat v3_client.txt
2 changes: 1 addition & 1 deletion .github/workflows/socketio-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: cargo test
- run: cargo test --all-features
e2e:
runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion engineioxide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ tower = "0.4.13"
tracing = "0.1.37"
rand = "0.8.5"
base64id = { version = "0.3.1", features = ["std", "rand", "serde"] }
cfg-if = "1.0.0"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] }

[[bench]]
name = "benchmark_polling"
harness = false
harness = false

[features]
default = ["v4"]
v4 = []
v3 = []
20 changes: 20 additions & 0 deletions engineioxide/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
```

### Supported Protocols
You can enable support for other EngineIO protocol implementations through feature flags.
The latest supported protocol version is enabled by default.

To add support for another protocol version, adjust your dependency configuration accordingly:

```toml
[dependencies]
# Enables the `v3` protocol (`v4` is also implicitly enabled, as it's the default).
engineioxide = { version = "0.3.0", features = ["v3"] }
```

To enable *a single protocol version only*, disable default features:

```toml
[dependencies]
# Enables the `v3` protocol only.
engineioxide = { version = "0.3.0", features = ["v3"], default-features = false }
```
1 change: 1 addition & 0 deletions engineioxide/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl EngineIoConfigBuilder {
config: EngineIoConfig::default(),
}
}

/// The path to listen for engine.io requests on.
/// Defaults to "/engine.io".
pub fn req_path(mut self, req_path: String) -> Self {
Expand Down
Loading