aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-04-10 23:03:50 +0100
committerubq323 <ubq323@ubq323.website>2024-04-11 13:35:06 +0100
commit79a9af88e53a6b0f7070a5fe97bbd399d139d00d (patch)
tree8df45e69d9d3d9ccab483b650f1469eb2118ce6f /client
parent2677d3ae0f4f5323ca67c6436cd3a55fd4fe8021 (diff)
the PAINT is now MULTIPLAYER !!!!!
Diffstat (limited to 'client')
-rw-r--r--client/main.ha18
1 files changed, 17 insertions, 1 deletions
diff --git a/client/main.ha b/client/main.ha
index 6c9208a..542c8f9 100644
--- a/client/main.ha
+++ b/client/main.ha
@@ -6,6 +6,8 @@ use net::dial;
use drawing;
use drawing::{pos};
use client::paintui;
+use unix::poll;
+use packet_reader;
def CHUNKSIZE = 512;
def NCHUNKS = 4;
@@ -43,7 +45,10 @@ export fn main() void = {
case let err: net::error =>
fmt::fatal("couldn't connect to server:",net::strerror(err));
};
-
+ const pollfd: [1]poll::pollfd = [ poll::pollfd {
+ fd = conn, events=poll::event::POLLIN, revents = 0
+ }];
+ const packet_reader = packet_reader::new();
// paintui state
let pstate = paintui::state { ... };
@@ -84,6 +89,17 @@ export fn main() void = {
drawing::send_op(conn, op)!;
};
+ const n = poll::poll(pollfd, poll::NONBLOCK)!;
+ if (n > 0) {
+ fmt::println("data available")!;
+ packet_reader::read(&packet_reader, conn)!;
+ for (const packet_bytes => packet_reader::next(&packet_reader)) {
+ const op = drawing::deser_op(packet_bytes);
+ drawing::perform(pictures, op);
+ };
+ };
+
+
for (let i = 0z; i < len(pictures); i += 1) {
const psurf = picture_surfaces[i];
const pic = &pictures[i];