Improve send_message, recv_message API, add support for encoding last will, fix decoding of QOS (#24)
* recv_message now returns topic as well as data * send_message accepts byte slice instead of &str * Add last will encoding * Fix QOS decoding
This commit is contained in:
@@ -80,7 +80,7 @@ async fn publish_core<'b>(
|
||||
"[Publisher] Sending new message {} to topic {}",
|
||||
message, topic
|
||||
);
|
||||
result = client.send_message(topic, message).await;
|
||||
result = client.send_message(topic, message.as_bytes()).await;
|
||||
info!("[PUBLISHER] sent");
|
||||
if err == true {
|
||||
assert_err!(result);
|
||||
@@ -174,7 +174,7 @@ async fn receive_core<'b>(
|
||||
info!("[Receiver] Waiting for new message!");
|
||||
let msg = client.receive_message().await;
|
||||
assert_ok!(msg);
|
||||
let act_message = String::from_utf8_lossy(msg?);
|
||||
let act_message = String::from_utf8_lossy(msg?.1);
|
||||
info!("[Receiver] Got new message: {}", act_message);
|
||||
assert_eq!(act_message, MSG);
|
||||
|
||||
@@ -208,14 +208,14 @@ async fn receive_core_multiple<'b, const TOPICS: usize>(
|
||||
{
|
||||
let msg = client.receive_message().await;
|
||||
assert_ok!(msg);
|
||||
let act_message = String::from_utf8_lossy(msg?);
|
||||
let act_message = String::from_utf8_lossy(msg?.1);
|
||||
info!("[Receiver] Got new message: {}", act_message);
|
||||
assert_eq!(act_message, MSG);
|
||||
}
|
||||
{
|
||||
let msg_sec = client.receive_message().await;
|
||||
assert_ok!(msg_sec);
|
||||
let act_message_second = String::from_utf8_lossy(msg_sec?);
|
||||
let act_message_second = String::from_utf8_lossy(msg_sec?.1);
|
||||
info!("[Receiver] Got new message: {}", act_message_second);
|
||||
assert_eq!(act_message_second, MSG);
|
||||
}
|
||||
@@ -365,14 +365,14 @@ async fn receive_multiple_second_unsub<const TOPICS: usize>(
|
||||
{
|
||||
let msg = { client.receive_message().await };
|
||||
assert_ok!(msg);
|
||||
let act_message = String::from_utf8_lossy(msg?);
|
||||
let act_message = String::from_utf8_lossy(msg?.1);
|
||||
info!("[Receiver] Got new message: {}", act_message);
|
||||
assert_eq!(act_message, msg_t1);
|
||||
}
|
||||
{
|
||||
let msg_sec = { client.receive_message().await };
|
||||
assert_ok!(msg_sec);
|
||||
let act_message_second = String::from_utf8_lossy(msg_sec?);
|
||||
let act_message_second = String::from_utf8_lossy(msg_sec?.1);
|
||||
info!("[Receiver] Got new message: {}", act_message_second);
|
||||
assert_eq!(act_message_second, msg_t2);
|
||||
}
|
||||
@@ -386,7 +386,7 @@ async fn receive_multiple_second_unsub<const TOPICS: usize>(
|
||||
{
|
||||
let msg = { client.receive_message().await };
|
||||
assert_ok!(msg);
|
||||
let act_message = String::from_utf8_lossy(msg?);
|
||||
let act_message = String::from_utf8_lossy(msg?.1);
|
||||
info!("[Receiver] Got new message: {}", act_message);
|
||||
assert_eq!(act_message, msg_t1);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ async fn publish_core<'b>(
|
||||
info!("[Publisher] Sending new message {} to topic {}", MSG, topic);
|
||||
let mut count = 0;
|
||||
loop {
|
||||
result = client.send_message(topic, MSG).await;
|
||||
result = client.send_message(topic, MSG.as_bytes()).await;
|
||||
info!("[PUBLISHER] sent {}", count);
|
||||
assert_ok!(result);
|
||||
count = count + 1;
|
||||
@@ -145,7 +145,7 @@ async fn receive_core<'b>(
|
||||
loop {
|
||||
let msg = client.receive_message().await;
|
||||
assert_ok!(msg);
|
||||
let act_message = String::from_utf8_lossy(msg?);
|
||||
let act_message = String::from_utf8_lossy(msg?.1);
|
||||
info!("[Receiver] Got new {}. message: {}", count, act_message);
|
||||
assert_eq!(act_message, MSG);
|
||||
count = count + 1;
|
||||
|
||||
Reference in New Issue
Block a user