Skip to content

Commit

Permalink
feat(http): support websocket server
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarisW committed Aug 7, 2024
1 parent 62cf986 commit 3800ea5
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions volo-http/src/server/utils/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,22 +624,19 @@ mod websocket_tests {
ws.set_config(
WebSocketConfig::new().set_protocols(["graphql-ws", "graphql-transport-ws"]),
)
.on_protocol([(
"graphql-ws",
|mut socket: WebSocket| async move {
while let Some(Ok(msg)) = socket.next().await {
match msg {
Message::Text(text) => {
socket
.send(Message::Text(text.add("-graphql-ws")))
.await
.unwrap();
}
_ => {}
.on_protocol([("graphql-ws", |mut socket: WebSocket| async move {
while let Some(Ok(msg)) = socket.next().await {
match msg {
Message::Text(text) => {
socket
.send(Message::Text(text.add("-graphql-ws")))
.await
.unwrap();
}
_ => {}
}
},
)])
}
})])
.on_upgrade(|_| async {})
}

Expand Down

0 comments on commit 3800ea5

Please sign in to comment.