aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Daniel López Azaña <daniloaz@gmail.com>2024-03-28 20:21:52 +0100
committerLibravatar Daniel López Azaña <daniloaz@gmail.com>2024-03-28 20:21:52 +0100
commit5c80b291fc776a7114572cebff898a7b3bf0671b (patch)
tree85f3f863f414a15773caa852aaf58a5e918910ae /src/main.rs
parente1c0e90581b7ce97f87ddf43267ceb32e28447e3 (diff)
✨ (lib.rs): introduce `ls_client` module as a cleaner naming convention
✨ (ls_client.rs): add `LightstreamerClient` struct and associated methods for managing communication with Lightstreamer Server ✨ (main.rs): update imports to use new `ls_client` module and add data adapter and snapshot configuration to subscription ♻️ (lib.rs): refactor `lightstreamer_client` to `ls_client` for consistency with new module name 📝 (ls_client.rs): add comprehensive documentation for `LightstreamerClient` and its methods ✨ (subscription.rs): add Snapshot enum to define snapshot delivery preferences ♻️ (subscription.rs): refactor requested_snapshot to use Snapshot enum for clarity 💡 (subscription.rs): update comments to reflect changes in snapshot handling
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 2dddb0d..5c2acc5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,10 @@
-use crate::item_update::ItemUpdate;
-use crate::subscription::{Subscription, SubscriptionMode};
-use crate::subscription_listener::SubscriptionListener;
+use lightstreamer_client::item_update::ItemUpdate;
+use lightstreamer_client::ls_client::LightstreamerClient;
+use lightstreamer_client::subscription::{Snapshot, Subscription, SubscriptionMode};
+use lightstreamer_client::subscription_listener::SubscriptionListener;
use futures::stream::StreamExt;
use futures::SinkExt;
-use lightstreamer_client::lightstreamer_client::LightstreamerClient;
use reqwest::Client;
use serde_urlencoded;
use std::error::Error;
@@ -12,10 +12,6 @@ use std::sync::Arc;
use tokio::sync::Mutex;
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
-mod item_update;
-mod subscription;
-mod subscription_listener;
-
async fn establish_persistent_http_connection(
session_id_shared: Arc<Mutex<String>>,
) -> Result<(), reqwest::Error> {
@@ -225,6 +221,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
)?;
subscription.add_listener(Box::new(MySubscriptionListener {}));
+ subscription.set_data_adapter(Some(String::from("QUOTE_ADAPTER")))?;
+ subscription.set_requested_snapshot(Some(Snapshot::Yes))?;
let client = LightstreamerClient::new(
Some("http://push.lightstreamer.com/lightstreamer"),