ableos/sysdata/libraries/sunset_proto/src/server.hb

34 lines
879 B
Plaintext
Raw Normal View History

2024-11-10 12:57:48 -06:00
.{math, log, string, random, buffer, memory} := @use("../../stn/src/lib.hb");
.{Surface, new_surface} := @use("../../render/src/lib.hb");
.{WindowWrapper, WindowID, WindowProps, WindowMessage, BUFFER} := @use("./lib.hb")
WindowServer := struct {window_count: uint, buffer_id: uint}
server := @as(?WindowServer, null)
new_window_id := fn(): WindowID {
return random.any(uint)
}
init := fn(): bool {
log.info("server: starting server\0")
server = .(0, buffer.create(BUFFER))
return true
}
recieve := fn(): ?WindowMessage {
if server == null {
log.error("server: (request_new) server is null. did you init the client?\0")
return null
}
buf := memory.uninit(WindowMessage)
buffer.recv(WindowMessage, @unwrap(server).buffer_id, @bitcast(&buf))
if memory.is_uninit(WindowMessage, &buf) {
return null
}
return buf
}
should_shutdown := fn(): bool {
return false
}