summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
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];