diff options
author | 2024-03-28 19:19:46 +0100 | |
---|---|---|
committer | 2024-03-28 19:19:46 +0100 | |
commit | e1c0e90581b7ce97f87ddf43267ceb32e28447e3 (patch) | |
tree | a347bfed5552256fcbe5d54798814a1a1d24cf0a /src/main.rs | |
parent | b4e12fd1165b5e3960a1294dadec45eb40893b37 (diff) |
✨ (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
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 30 |
1 files changed, 25 insertions, 5 deletions
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<dyn Error>> { 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(()) } |