1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

Added version code sending.

This commit is contained in:
Koen 2023-12-07 16:56:20 +01:00
parent 18b61d549c
commit 33a8d684bf
9 changed files with 68 additions and 10 deletions

View file

@ -1,6 +1,6 @@
use std::sync::{atomic::{AtomicBool, Ordering}, Arc};
use crate::{models::{PlaybackUpdateMessage, VolumeUpdateMessage, PlaybackErrorMessage}, transport::Transport};
use crate::{models::{PlaybackUpdateMessage, VolumeUpdateMessage, PlaybackErrorMessage, VersionMessage}, transport::Transport};
use serde::Serialize;
#[derive(Debug)]
@ -23,7 +23,8 @@ pub enum Opcode {
VolumeUpdate = 7,
SetVolume = 8,
PlaybackError = 9,
SetSpeed = 10
SetSpeed = 10,
Version = 11
}
impl Opcode {
@ -40,6 +41,7 @@ impl Opcode {
8 => Opcode::SetVolume,
9 => Opcode::PlaybackError,
10 => Opcode::SetSpeed,
11 => Opcode::Version,
_ => panic!("Unknown value: {}", value),
}
}
@ -219,6 +221,13 @@ impl FCastSession<'_> {
}
}
}
Opcode::Version => {
if let Some(body_str) = body {
if let Ok(version_msg) = serde_json::from_str::<VersionMessage>(body_str) {
println!("Received version {:?}", version_msg);
}
}
}
_ => {
println!("Error handling packet");
}

View file

@ -64,4 +64,9 @@ impl SetSpeedMessage {
#[derive(Deserialize, Debug)]
pub struct PlaybackErrorMessage {
pub message: String,
}
#[derive(Deserialize, Debug)]
pub struct VersionMessage {
pub version: u64,
}