Skip to content

Commit

Permalink
rename host to virtualhost
Browse files Browse the repository at this point in the history
  • Loading branch information
zuisong committed Dec 27, 2023
1 parent a54c6fb commit 3fa722c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@ use anyhow::{anyhow, bail};
/// Connect to a STOMP server via TCP, including the connection handshake.
/// If successful, returns a tuple of a message stream and a sender,
/// which may be used to receive and send messages respectively.
///
/// `virtualhost` If no specific virtualhost is desired, it is recommended
/// to set this to the same as the host name that the socket
/// was established against (i.e, the same as the server address).
pub async fn connect(
server: impl tokio::net::ToSocketAddrs,
host: impl Into<String>,
virtualhost: impl Into<String>,

Check warning on line 23 in src/client.rs

View check run for this annotation

Codecov / codecov/patch

src/client.rs#L22-L23

Added lines #L22 - L23 were not covered by tests
login: Option<String>,
passcode: Option<String>,
) -> Result<ClientTransport> {
let tcp = TcpStream::connect(server).await?;

Check warning on line 27 in src/client.rs

View check run for this annotation

Codecov / codecov/patch

src/client.rs#L27

Added line #L27 was not covered by tests
let mut transport = ClientCodec.framed(tcp);
client_handshake(&mut transport, host.into(), login, passcode).await?;
client_handshake(&mut transport, virtualhost.into(), login, passcode).await?;

Check warning on line 29 in src/client.rs

View check run for this annotation

Codecov / codecov/patch

src/client.rs#L29

Added line #L29 was not covered by tests
Ok(transport)
}

async fn client_handshake(
transport: &mut ClientTransport,
host: String,
virtualhost: String,

Check warning on line 35 in src/client.rs

View check run for this annotation

Codecov / codecov/patch

src/client.rs#L35

Added line #L35 was not covered by tests
login: Option<String>,
passcode: Option<String>,
) -> Result<()> {
let connect = Message {
content: ToServer::Connect {
accept_version: "1.2".into(),
host,
host: virtualhost,

Check warning on line 42 in src/client.rs

View check run for this annotation

Codecov / codecov/patch

src/client.rs#L42

Added line #L42 was not covered by tests
login,
passcode,
heartbeat: None,
Expand Down

0 comments on commit 3fa722c

Please sign in to comment.