pub async fn room_send(
        &self,
        room_id: &RoomId,
        content: impl Into<AnyMessageEventContent>,
        txn_id: Option<Uuid>,
    ) -> Result<send_message_event::Response> {
        #[cfg(not(feature = "encryption"))]
        let content: AnyMessageEventContent = content.into();

        #[cfg(feature = "encryption")]
        let content = if self.is_room_encrypted(room_id).await {
            self.preshare_group_session(room_id).await?;
            AnyMessageEventContent::RoomEncrypted(self.base_client.encrypt(room_id, content).await?)
        } else {
            content.into()
        };

        let txn_id = txn_id.unwrap_or_else(Uuid::new_v4).to_string();
        let request = send_message_event::Request::new(&room_id, &txn_id, &content);

        let response = self.send(request).await?;
        Ok(response)
    }
/// Send a room message to the homeserver.
///
/// Returns the parsed response from the server.
///
/// If the encryption feature is enabled this method will transparently
/// encrypt the room message if the given room is encrypted.
///
/// # Arguments
///
/// * `room_id` -  The id of the room that should receive the message.
///
/// * `content` - The content of the message event.
///
/// * `txn_id` - A unique `Uuid` that can be attached to a `MessageEvent`
/// held in its unsigned field as `transaction_id`. If not given one is
/// created for the message.
///
/// # Example
/// ```no_run
/// # use matrix_sdk::Room;
/// # use std::sync::{Arc, RwLock};
/// # use matrix_sdk::{Client, SyncSettings};
/// # use url::Url;
/// # use futures::executor::block_on;
/// # use matrix_sdk::identifiers::room_id;
/// # use std::convert::TryFrom;
/// use matrix_sdk::events::{
///     AnyMessageEventContent,
///     room::message::{MessageEventContent, TextMessageEventContent},
/// };
/// # block_on(async {
/// # let homeserver = Url::parse("http://localhost:8080").unwrap();
/// # let mut client = Client::new(homeserver).unwrap();
/// # let room_id = room_id!("!test:localhost");
/// use matrix_sdk_common::uuid::Uuid;
///
/// let content = AnyMessageEventContent::RoomMessage(
///     MessageEventContent::Text(TextMessageEventContent::plain("Hello world"))
/// );
///
/// let txn_id = Uuid::new_v4();
/// client.room_send(&room_id, content, Some(txn_id)).await.unwrap();
/// # })
/// ```
Send a room message to the homeserver.
Returns the parsed response from the server.

If the encryption feature is enabled this method will transparently
encrypt the room message if the given room is encrypted.
Send a room message to the homeserver . Returns the parsed response from the server . If the encryption feature is enabled this method will transparently encrypt the room message if the given room is encrypted .
pub async fn room_send(
        &self,
        room_id: &RoomId,
        content: impl Into<AnyMessageEventContent>,
        txn_id: Option<Uuid>,
    ) -> Result<send_message_event::Response> {
        #[cfg(not(feature = "encryption"))]
        let content: AnyMessageEventContent = content.into();
        #[cfg(feature = "encryption")]
        let content = if self.is_room_encrypted(room_id).await {
            self.preshare_group_session(room_id).await?;
            AnyMessageEventContent::RoomEncrypted(self.base_client.encrypt(room_id, content).await?)
        } else {
            content.into()
        };
        let txn_id = txn_id.unwrap_or_else(Uuid::new_v4).to_string();
        let request = send_message_event::Request::new(&room_id, &txn_id, &content);
        let response = self.send(request).await?;
        Ok(response)
    }
pub async fn room_send ( & self , room_id : & RoomId , content : impl Into < AnyMessageEventContent > , txn_id : Option < Uuid > , ) -> Result < send_message_event :: Response > { # [ cfg ( not ( feature " " ) ) ] let content : AnyMessageEventContent = content . into ( ) ; # [ cfg ( feature " " ) ] let content = if self . is_room_encrypted ( room_id ) . await { self . preshare_group_session ( room_id ) . await ? ; AnyMessageEventContent :: RoomEncrypted ( self . base_client . encrypt ( room_id , content ) . await ? ) } else { content . into ( ) } ; let txn_id = txn_id . unwrap_or_else ( Uuid :: new_v4 ) . to_string ( ) ; let request = send_message_event :: Request :: new ( & room_id , & txn_id , & content ) ; let response = self . send ( request ) . await ? ; Ok ( response ) }
Send a room message to the homeserver.
Send a room message to the homeserver .
&self
room_id
&RoomId
content
impl Into<AnyMessageEventContent>
txn_id
Option<Uuid>
&self
room_id
&RoomId
content
impl Into<AnyMessageEventContent>
txn_id
Option<Uuid>
example
None
use matrix_sdk::room;
None
use std::sync::{arc, rwlock};
None
use matrix_sdk::{client, syncsettings};
None
use url::url;
None
use futures::executor::block_on;
None
use matrix_sdk::identifiers::room_id;
None
use std::convert::tryfrom;
use matrix_sdk::events::{
AnyMessageEventContent,
room::message::{MessageEventContent, TextMessageEventContent},
}.
use matrix_sdk :: events :: { AnyMessageEventContent room :: message :: { MessageEventContent TextMessageEventContent } } .
block_on(async {
None
let homeserver = url::parse("http://localhost:8080").unwrap();
None
let mut client = client::new(homeserver).unwrap();
None
let room_id = room_id!("!test:localhost");
use matrix_sdk_common::uuid::Uuid.

let content = AnyMessageEventContent::RoomMessage(
MessageEventContent::Text(TextMessageEventContent::plain("Hello world"))
).

let txn_id = Uuid::new_v4();
client.room_send(&room_id, content, Some(txn_id)).await.unwrap().
use matrix_sdk_common :: uuid :: Uuid . let content = AnyMessageEventContent :: RoomMessage ( MessageEventContent :: Text ( TextMessageEventContent :: plain ( " Hello world " )) ) . let txn_id = Uuid :: new_v4 () ; client . room_send ( &room_id content Some ( txn_id )) . await . unwrap () .
})
None