diff options
author | 2024-04-05 17:38:05 +0200 | |
---|---|---|
committer | 2024-04-05 17:38:05 +0200 | |
commit | 46cd2fd0af59d562e9aff31193b3d43c155d0a1e (patch) | |
tree | e6b71c55a6dd6c3a1b1cce773b46d82b9506c712 /src/ls_client.rs | |
parent | 1d74478512faafdb2263b0d11773190c9efe3190 (diff) |
⬆️ (Cargo.toml): bump version from 0.1.2 to 0.1.3
✨ (connection_details.rs): add user and password parameters to ConnectionDetails::new
♻️ (ls_client.rs): refactor user and password handling into ConnectionDetails
🐛 (ls_client.rs): downgrade TLCP protocol version from 2.5.0 to 2.4.0
✨ (main.rs): update LightstreamerClient::new call to include optional username and password parameters
Diffstat (limited to 'src/ls_client.rs')
-rw-r--r-- | src/ls_client.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/ls_client.rs b/src/ls_client.rs index 12fcd8b..5d37151 100644 --- a/src/ls_client.rs +++ b/src/ls_client.rs @@ -212,15 +212,6 @@ impl LightstreamerClient { /* - if let Some(user) = &self.connection_details.get_user() { - params.insert("LS_user", user); - } - - if let Some(password) = &self.connection_details.get_password() { - params.insert("LS_password", password); - } - - if let Some(requested_max_bandwidth) = self.connection_options.get_requested_max_bandwidth() { params.insert("LS_requested_max_bandwidth", &requested_max_bandwidth.to_string()); } @@ -322,7 +313,7 @@ impl LightstreamerClient { ) .header( HeaderName::from_static("sec-websocket-protocol"), - HeaderValue::from_static("TLCP-2.5.0.lightstreamer.com"), + HeaderValue::from_static("TLCP-2.4.0.lightstreamer.com"), ) .header( HeaderName::from_static("sec-websocket-version"), @@ -516,12 +507,18 @@ 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 params: Vec<(&str, &str)> = vec![ + let mut params: Vec<(&str, &str)> = vec![ ("LS_adapter_set", &ls_adapter_set), ("LS_cid", "mgQkwtwdysogQz2BJ4Ji%20kOj2Bg"), ("LS_send_sync", &ls_send_sync), - ("LS_protocol", "TLCP-2.5.0"), + ("LS_protocol", "TLCP-2.4.0"), ]; + if let Some(user) = &self.connection_details.get_user() { + params.push(("LS_user", user)); + } + if let Some(password) = &self.connection_details.get_password() { + params.push(("LS_password", password)); + } let encoded_params = serde_urlencoded::to_string(¶ms)?; write_stream .send(Message::Text(format!("create_session\r\n{}\n", encoded_params))) @@ -704,8 +701,11 @@ impl LightstreamerClient { pub fn new( server_address: Option<&str>, adapter_set: Option<&str>, + username: Option<&str>, + password: Option<&str>, ) -> Result<LightstreamerClient, Box<dyn Error>> { - let connection_details = ConnectionDetails::new(server_address, adapter_set)?; + let connection_details = + ConnectionDetails::new(server_address, adapter_set, username, password)?; let connection_options = ConnectionOptions::default(); Ok(LightstreamerClient { |