Struct rust_cast::channels::receiver::ReceiverChannel
source · Implementations§
source§impl<'a, W> ReceiverChannel<'a, W>where
W: Write + Read,
impl<'a, W> ReceiverChannel<'a, W>where
W: Write + Read,
pub fn new<S>(
sender: S,
receiver: S,
message_manager: Rc<MessageManager<W>>
) -> ReceiverChannel<'a, W>where
S: Into<Cow<'a, str>>,
sourcepub fn launch_app(&self, app: &CastDeviceApp) -> Result<Application, Error>
pub fn launch_app(&self, app: &CastDeviceApp) -> Result<Application, Error>
sourcepub fn broadcast_message<M: Serialize>(
&self,
namespace: &str,
message: &M
) -> Result<(), Error>
pub fn broadcast_message<M: Serialize>(
&self,
namespace: &str,
message: &M
) -> Result<(), Error>
Broadcasts a message over a cast device’s message bus.
Receiver can observe messages using context.addCustomMessageListener
with custom namespace.
context.addCustomMessageListener('urn:x-cast:com.example.castdata', function(customEvent) {
// do something with message
});
Namespace should start with urn:x-cast:
Arguments
namespace
- Message namespace that should start withurn:x-cast:
.message
- Message instance to send.
sourcepub fn stop_app<S>(&self, session_id: S) -> Result<(), Error>where
S: Into<Cow<'a, str>>,
pub fn stop_app<S>(&self, session_id: S) -> Result<(), Error>where
S: Into<Cow<'a, str>>,
Stops currently active app using corresponding session_id
.
Arguments
session_id
- identifier of the active application session fromApplication
instance.
sourcepub fn get_status(&self) -> Result<Status, Error>
pub fn get_status(&self) -> Result<Status, Error>
Retrieves status of the cast device receiver.
Return value
Returned Result
should consist of either Status
instance or an Error
.
sourcepub fn set_volume<T>(&self, volume: T) -> Result<Volume, Error>where
T: Into<Volume>,
pub fn set_volume<T>(&self, volume: T) -> Result<Volume, Error>where
T: Into<Volume>,
Sets volume for the active cast device.
Arguments
volume
- anything that can be converted to a validVolume
structure. It’s possible to set volume level, mute/unmute state or both altogether.
Return value
Actual Volume
instance returned by receiver.
Errors
Usually method can fail only if network connection with cast device is lost for some reason.