Skip to content

Commit f991d18

Browse files
committed
Act on multiple received messages
1 parent 52e92bb commit f991d18

File tree

3 files changed

+85
-96
lines changed

3 files changed

+85
-96
lines changed

Cargo.lock

Lines changed: 57 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ simple_logger = { version = "5.0.0", default-features = false, features = [
2828
"stderr",
2929
"colors",
3030
] }
31-
slimproto = "0.1.23"
32-
symphonia = { version = "0.5.4", features = ["all-codecs", "all-formats"] }
31+
slimproto = "0.1.24"
32+
symphonia = { version = "*", git = "https://github.com/pdeljanov/Symphonia.git", branch = "dev-0.6", features = [
33+
"all-codecs",
34+
"all-formats",
35+
] }
3336

3437
[profile.dev.package."symphonia"]
3538
opt-level = 3

src/proto.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn run(
2727
}))
2828
.ok();
2929

30-
let mut syncgroupid = String::new();
30+
let syncgroupid = String::new();
3131
// Outer loop to reconnect to a different server and
3232
// update server details when a Serv message is received
3333
'outer: loop {
@@ -77,33 +77,31 @@ pub fn run(
7777
});
7878

7979
// Inner read loop
80-
loop {
80+
'zzz: loop {
8181
match rx.framed_read() {
82-
Ok(msg) => {
83-
// println!("{:?}", msg);
84-
match msg {
85-
// Request to change to another server
86-
ServerMessage::Serv {
87-
ip_address: ip,
88-
sync_group_id: sgid,
89-
} => {
90-
if let Some(ref sgid) = sgid {
91-
syncgroupid = sgid.to_owned();
82+
Ok(messages) => {
83+
for msg in messages.into_iter() {
84+
// println!("{:?}", msg);
85+
match msg {
86+
// Request to change to another server
87+
ServerMessage::Serv {
88+
ip_address: ip,
89+
sync_group_id: sgid,
90+
} => {
91+
server = (ip, sgid).into();
92+
// Now inform the main thread
93+
slim_rx_in
94+
.send(Some(ServerMessage::Serv {
95+
ip_address: ip,
96+
sync_group_id: None,
97+
}))
98+
.ok();
99+
break 'zzz;
92100
}
93101

94-
server = (ip, sgid).into();
95-
// Now inform the main thread
96-
slim_rx_in
97-
.send(Some(ServerMessage::Serv {
98-
ip_address: ip,
99-
sync_group_id: None,
100-
}))
101-
.ok();
102-
break;
103-
}
104-
105-
_ => {
106-
slim_rx_in.send(Some(msg)).ok();
102+
_ => {
103+
slim_rx_in.send(Some(msg)).ok();
104+
}
107105
}
108106
}
109107
}

0 commit comments

Comments
 (0)