Skip to content

Commit

Permalink
Pass the socket address down to WebsocketHandler::accept.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtzxporter committed Nov 21, 2024
1 parent f891104 commit 4cdf19f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

### Fixed

# 0.1.32

### Changed
- **BREAKING**: Changed the signature of `WebsocketHandler::accept()` to also pass the connecting socket address down.

# 0.1.31

### Changed
- Updated dependencies.

# 0.1.30

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ tracing = { version = "0.1", default-features = false, features = ["std"] }
tracing-subscriber = "0.3"
dashmap = "6.0.1"

hydra-macros = { version = "0.1.31", path = "./hydra-macros" }
hydra = { version = "0.1.31", path = "./hydra", default-features = false }
hydra-macros = { version = "0.1.32", path = "./hydra-macros" }
hydra = { version = "0.1.32", path = "./hydra", default-features = false }

[profile.release]
lto = "fat"
Expand Down
2 changes: 1 addition & 1 deletion hydra-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydra-macros"
version = "0.1.31"
version = "0.1.32"
edition = "2021"
license.workspace = true
repository.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion hydra-websockets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydra-websockets"
version = "0.1.31"
version = "0.1.32"
edition = "2021"
readme = "./README.md"
license.workspace = true
Expand Down
1 change: 1 addition & 0 deletions hydra-websockets/examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl WebsocketHandler for MyWebsocketHandler {
type Message = ();

fn accept(
_address: SocketAddr,
_request: &WebsocketRequest,
response: WebsocketResponse,
) -> Result<(WebsocketResponse, Self), ExitReason> {
Expand Down
2 changes: 2 additions & 0 deletions hydra-websockets/src/websocket_handler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::future::Future;
use std::net::SocketAddr;

use futures_util::stream;
use futures_util::SinkExt;
Expand Down Expand Up @@ -34,6 +35,7 @@ where
///
/// You can extract information from the request and put it in your handler state.
fn accept(
address: SocketAddr,
request: &WebsocketRequest,
response: WebsocketResponse,
) -> Result<(WebsocketResponse, Self), ExitReason>;
Expand Down
2 changes: 1 addition & 1 deletion hydra-websockets/src/websocket_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
let mut handler: Option<T> = None;

let callback = |request: &WebsocketRequest, response: WebsocketResponse| match T::accept(
request, response,
address, request, response,
) {
Ok((response, rhandler)) => {
handler = Some(rhandler);
Expand Down
2 changes: 1 addition & 1 deletion hydra/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydra"
version = "0.1.31"
version = "0.1.32"
edition = "2021"
readme.workspace = true
license.workspace = true
Expand Down

0 comments on commit 4cdf19f

Please sign in to comment.