Skip to content

Commit e612a5b

Browse files
committed
revamp ui and add new shapes
1 parent 6f3e15e commit e612a5b

File tree

5 files changed

+232
-250
lines changed

5 files changed

+232
-250
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "draw-together"
3-
version = "2.0.1"
3+
version = "2.1.0"
44
edition = "2021"
55

66
[[bin]]

src/data.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ use tokio::{
66
};
77

88
pub enum Action {
9-
Draw,
9+
DrawCubeNormal,
1010
Erase,
11+
DrawCubeHollow,
12+
DrawCircleNormal,
13+
DrawCircleHollow,
14+
DrawTriangleNormal,
15+
DrawTriangleHollow,
1116
}
1217

1318
pub struct ClientMessage {
@@ -27,8 +32,13 @@ impl ClientMessage {
2732
}
2833

2934
let action = match data[0] {
30-
0 => Action::Draw,
35+
0 => Action::DrawCubeNormal,
3136
1 => Action::Erase,
37+
2 => Action::DrawCubeHollow,
38+
3 => Action::DrawCircleNormal,
39+
4 => Action::DrawCircleHollow,
40+
5 => Action::DrawTriangleNormal,
41+
6 => Action::DrawTriangleHollow,
3242
_ => return None,
3343
};
3444

@@ -54,8 +64,13 @@ impl ClientMessage {
5464
let mut buf = [0; 9];
5565

5666
buf[0] = match self.action {
57-
Action::Draw => 0,
67+
Action::DrawCubeNormal => 0,
5868
Action::Erase => 1,
69+
Action::DrawCubeHollow => 2,
70+
Action::DrawCircleNormal => 3,
71+
Action::DrawCircleHollow => 4,
72+
Action::DrawTriangleNormal => 5,
73+
Action::DrawTriangleHollow => 6,
5974
};
6075

6176
buf[1..3].copy_from_slice(&self.x.to_le_bytes());

src/main.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ async fn handle_ws(
121121
break;
122122
}
123123

124-
let parsed = data::ClientMessage::decode(&ws_data.unwrap().unwrap().into_data());
124+
let ws_data = ws_data.unwrap();
125+
if ws_data.is_err() {
126+
break;
127+
}
128+
129+
let parsed = data::ClientMessage::decode(&ws_data.unwrap().into_data());
125130

126131
if parsed.is_none() {
127132
continue;

0 commit comments

Comments
 (0)