Wokring streaming

This commit is contained in:
2026-08-05 04:55:20 +02:00
parent 4b15dce8b8
commit 72353b1c81
3 changed files with 698 additions and 5 deletions
+22 -2
View File
@@ -1,5 +1,25 @@
pub mod executor;
fn main() {
println!("Hello, world!");
use futures_util::{SinkExt, StreamExt};
use serde_json::json;
use tokio_tungstenite::connect_async;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let (mut ws, _) = connect_async("wss://pumpdev.io/ws").await?;
ws.send(tokio_tungstenite::tungstenite::Message::Text(
json!({ "method": "subscribeNewToken" }).to_string().into(),
))
.await?;
while let Some(msg) = ws.next().await {
let msg = msg?;
if let tokio_tungstenite::tungstenite::Message::Text(text) = msg {
let token: serde_json::Value = serde_json::from_str(&text)?;
// println!("{} ({})", token.name, token.symbol);
println!("{:?}", token);
}
}
Ok(())
}