Skip to content

Commit

Permalink
Add ping/pong to websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhuachuang committed May 15, 2024
1 parent a46839f commit bd2b11f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![crate](https://img.shields.io/badge/crates.io-v0.10.3-green.svg)](https://crates.io/crates/tdn) [![doc](https://img.shields.io/badge/docs.rs-v0.10.3-blue.svg)](https://docs.rs/tdn)
[![crate](https://img.shields.io/badge/crates.io-v0.10.6-green.svg)](https://crates.io/crates/tdn) [![doc](https://img.shields.io/badge/docs.rs-v0.10.6-blue.svg)](https://docs.rs/tdn)

<h1 align="center"><img src="https://cympletech.com/logo/tdn_words.png" alt="TDN"></h1>

Expand Down
2 changes: 1 addition & 1 deletion tdn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tdn"
version = "0.10.5"
version = "0.10.6"
authors = ["Dev <[email protected]>"]
edition = "2021"
readme = "../README.md"
Expand Down
6 changes: 6 additions & 0 deletions tdn/src/rpc/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ async fn ws_connection(
}
Some(FutureResult::Stream(msg)) => {
let msg = msg.to_text().unwrap();
if msg == "ping" {
let s = WsMessage::from("pong".to_owned());
let _ = writer.send(s).await;
continue;
}

match parse_jsonrpc(msg.to_owned()) {
Ok(rpc_param) => {
send.send(RpcMessage::Request(id, rpc_param, None)).await?;
Expand Down

0 comments on commit bd2b11f

Please sign in to comment.