aboutsummaryrefslogtreecommitdiff
path: root/src/client/connection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/connection.rs')
-rw-r--r--src/client/connection.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/client/connection.rs b/src/client/connection.rs
index 21d452d..0205ba5 100644
--- a/src/client/connection.rs
+++ b/src/client/connection.rs
@@ -185,6 +185,14 @@ impl Connection {
}
}
+ /// Same as [Connection::send_message_on] but will log the error instead of returning it
+ pub fn try_send_message_on<T: serde::Serialize>(&self, channel_id: ChannelId, message: T) {
+ match self.send_message_on(channel_id, message) {
+ Ok(_) => {}
+ Err(err) => error!("try_send_message_on: {}", err),
+ }
+ }
+
pub fn send_payload<T: Into<Bytes>>(&self, payload: T) -> Result<(), QuinnetError> {
match self.default_channel {
Some(channel) => self.send_payload_on(channel, payload),
@@ -214,6 +222,14 @@ impl Connection {
}
}
+ /// Same as [Connection::send_payload_on] but will log the error instead of returning it
+ pub fn try_send_payload_on<T: Into<Bytes>>(&self, channel_id: ChannelId, payload: T) {
+ match self.send_payload_on(channel_id, payload) {
+ Ok(_) => {}
+ Err(err) => error!("try_send_payload_on: {}", err),
+ }
+ }
+
pub fn receive_payload(&mut self) -> Result<Option<Bytes>, QuinnetError> {
match &self.state {
ConnectionState::Disconnected => Err(QuinnetError::ConnectionClosed),