diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/ls_client.rs | 11 | ||||
-rw-r--r-- | src/subscription.rs | 5 |
3 files changed, 11 insertions, 7 deletions
@@ -1,6 +1,6 @@ [package] name = "lightstreamer-client" -version = "0.1.4" +version = "0.1.5" edition = "2021" authors = ["Daniel López Azaña <daniloaz@gmail.com>"] description = "A Rust client for Lightstreamer, designed to facilitate real-time communication with Lightstreamer servers." diff --git a/src/ls_client.rs b/src/ls_client.rs index 4d46dfb..95cdfba 100644 --- a/src/ls_client.rs +++ b/src/ls_client.rs @@ -123,6 +123,9 @@ impl LightstreamerClient { /// A constant string representing the version of the library. pub const LIB_VERSION: &'static str = "0.1.0"; + /// A constant string representing the version of the TLCP protocol used by the library. + pub const TLCP_VERSION: &'static str = "TLCP-2.4.0"; + /// Static method that can be used to share cookies between connections to the Server (performed by /// this library) and connections to other sites that are performed by the application. With this /// method, cookies received by the application can be added (or replaced if already present) to @@ -440,14 +443,12 @@ impl LightstreamerClient { // Prepare the subscription request. // let mut params: Vec<(&str, &str)> = vec![ - //("LS_session", session_id), ("LS_reqId", &ls_req_id), ("LS_op", "add"), ("LS_subId", &ls_sub_id), ("LS_mode", &ls_mode), ("LS_group", &ls_group), ("LS_schema", &ls_schema), - ("LS_data_adapter", &ls_data_adapter), ("LS_ack", "false"), ]; if ls_snapshot != "" { @@ -476,6 +477,9 @@ impl LightstreamerClient { "probe" => { println!("Received probe message from server: '{}'", clean_text); }, + "reqok" => { + println!("Received reqok message from server: '{}'", clean_text); + }, // // Subscription confirmation from server. // @@ -506,12 +510,10 @@ impl LightstreamerClient { }, }; let ls_send_sync = self.connection_options.get_send_sync().to_string(); - println!("self.connection_options.get_send_sync(): {:?}", self.connection_options.get_send_sync()); let mut params: Vec<(&str, &str)> = vec![ ("LS_adapter_set", &ls_adapter_set), ("LS_cid", "mgQkwtwdysogQz2BJ4Ji kOj2Bg"), ("LS_send_sync", &ls_send_sync), - ("LS_protocol", "TLCP-2.4.0"), ]; if let Some(user) = &self.connection_details.get_user() { params.push(("LS_user", user)); @@ -519,6 +521,7 @@ impl LightstreamerClient { if let Some(password) = &self.connection_details.get_password() { params.push(("LS_password", password)); } + params.push(("LS_protocol", Self::TLCP_VERSION)); let encoded_params = serde_urlencoded::to_string(¶ms)?; write_stream .send(Message::Text(format!("create_session\r\n{}\n", encoded_params))) diff --git a/src/subscription.rs b/src/subscription.rs index e008804..07c580c 100644 --- a/src/subscription.rs +++ b/src/subscription.rs @@ -1,5 +1,6 @@ use crate::subscription_listener::SubscriptionListener; use std::collections::HashMap; +use std::error::Error; use std::fmt::{self, Debug, Formatter}; /// Enum representing the snapshot delivery preferences to be requested to Lightstreamer Server for the items in the Subscription. @@ -116,9 +117,9 @@ impl Subscription { mode: SubscriptionMode, items: Option<Vec<String>>, fields: Option<Vec<String>>, - ) -> Result<Subscription, String> { + ) -> Result<Subscription, Box<dyn Error>> { if items.is_none() || fields.is_none() { - return Err("Items and fields must be provided".to_string()); + return Err("Items and fields must be provided".to_string().into()); } Ok(Subscription { |