publish_tcp/
publish_tcp.rs

1#[tokio::main]
2async fn main() -> Result<(), anyhow::Error> {
3    let client_type = simple_pub_sub::client::PubSubTcpClient {
4        server: "localhost".to_string(),
5        port: 6480,
6        cert: None,
7        cert_password: None,
8    };
9    // initialize the client.
10    let mut client =
11        simple_pub_sub::client::Client::new(simple_pub_sub::client::PubSubClient::Tcp(client_type));
12
13    client.connect().await?;
14    // publish to the given topic.
15    client
16        .publish(
17            "abc".to_string(),
18            "test message".to_string().into_bytes().to_vec(),
19        )
20        .await
21}