From e1c0e90581b7ce97f87ddf43267ceb32e28447e3 Mon Sep 17 00:00:00 2001 From: Daniel López Azaña Date: Thu, 28 Mar 2024 19:19:46 +0100 Subject: ✨ (client_listener.rs): Implement Debug trait for ClientListener for better logging ♻️ (connection_details.rs): Refactor ConnectionDetails to use Option for optional fields ♻️ (connection_details.rs): Change new constructor to accept &str and convert to String ✨ (connection_details.rs): Implement Debug trait for ConnectionDetails ♻️ (connection_options.rs): Implement Debug trait for ConnectionOptions ♻️ (lightstreamer_client.rs): Refactor LightstreamerClient to use Option for server_address and adapter_set ✨ (lightstreamer_client.rs): Implement Debug trait for LightstreamerClient ♻️ (main.rs): Update subscribe_to_channel function to use new control.txt URL and parameters ♻️ (main.rs): Update main function to use Option<&str> when creating LightstreamerClient ✨ (proxy.rs): Add Proxy struct and ProxyType enum to handle proxy configurations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 07a3bf4..2dddb0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -108,8 +108,20 @@ async fn establish_persistent_ws_connection( async fn subscribe_to_channel(session_id: String) -> Result<(), reqwest::Error> { let client = Client::new(); - let subscribe_url = "http://push.lightstreamer.com/lightstreamer/bind_session.txt"; - let params = [("LS_session", &session_id)]; + //let subscribe_url = "http://push.lightstreamer.com/lightstreamer/bind_session.txt"; + //let params = [("LS_session", &session_id)]; + let subscribe_url = + "http://push.lightstreamer.com/lightstreamer/control.txt?LS_protocol=TLCP-2.0.0"; + let params = [ + ("LS_session", &session_id), + ("LS_op", &"add".to_string()), + ("LS_subId", &"1".to_string()), + ("LS_data_adapter", &"CHAT_ROOM".to_string()), + ("LS_group", &"chat_room".to_string()), + ("LS_schema", &"timestamp message".to_string()), + ("LS_mode", &"DISTINCT".to_string()), + ("LS_reqId", &"1".to_string()), + ]; let response = client.post(subscribe_url).form(¶ms).send().await?; @@ -204,15 +216,23 @@ impl SubscriptionListener for MySubscriptionListener { async fn main() -> Result<(), Box> { let mut subscription = Subscription::new( SubscriptionMode::Merge, - Some(vec!["item1".to_string(),"item2".to_string(),"item3".to_string()]), - Some(vec!["stock_name".to_string(),"last_price".to_string()]), + Some(vec![ + "item1".to_string(), + "item2".to_string(), + "item3".to_string(), + ]), + Some(vec!["stock_name".to_string(), "last_price".to_string()]), )?; subscription.add_listener(Box::new(MySubscriptionListener {})); - let client = LightstreamerClient::new("http://push.lightstreamer.com/lightstreamer", "DEMO")?; + let client = LightstreamerClient::new( + Some("http://push.lightstreamer.com/lightstreamer"), + Some("DEMO"), + )?; println!("Subscription: {:?}", subscription); + println!("Client: {:?}", client); Ok(()) } -- cgit v1.2.3