aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ls_client.rs5
-rw-r--r--src/main.rs14
2 files changed, 12 insertions, 7 deletions
diff --git a/src/ls_client.rs b/src/ls_client.rs
index 214a722..59dd247 100644
--- a/src/ls_client.rs
+++ b/src/ls_client.rs
@@ -148,7 +148,10 @@ impl LightstreamerClient {
///
/// See also `ConnectionDetails.setServerAddress()`
pub fn connect(&mut self) -> Result<(), IllegalStateException> {
- // Implementation for connect
+ if self.server_address.is_none() {
+ return Err(IllegalStateException::new("No server address was configured."));
+ }
+
Ok(())
}
diff --git a/src/main.rs b/src/main.rs
index 5c2acc5..c120c1f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -210,7 +210,7 @@ impl SubscriptionListener for MySubscriptionListener {
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
- let mut subscription = Subscription::new(
+ let mut my_subscription = Subscription::new(
SubscriptionMode::Merge,
Some(vec![
"item1".to_string(),
@@ -220,17 +220,19 @@ async fn main() -> Result<(), Box<dyn Error>> {
Some(vec!["stock_name".to_string(), "last_price".to_string()]),
)?;
- subscription.add_listener(Box::new(MySubscriptionListener {}));
- subscription.set_data_adapter(Some(String::from("QUOTE_ADAPTER")))?;
- subscription.set_requested_snapshot(Some(Snapshot::Yes))?;
+ my_subscription.set_data_adapter(Some(String::from("QUOTE_ADAPTER")))?;
+ my_subscription.set_requested_snapshot(Some(Snapshot::Yes))?;
+ my_subscription.add_listener(Box::new(MySubscriptionListener {}));
- let client = LightstreamerClient::new(
+ let mut client = LightstreamerClient::new(
Some("http://push.lightstreamer.com/lightstreamer"),
Some("DEMO"),
)?;
- println!("Subscription: {:?}", subscription);
+ client.subscribe(my_subscription);
println!("Client: {:?}", client);
+ client.connect();
+
Ok(())
}