oopsie daisy forgot 2 super imponrtant methods

This commit is contained in:
2026-05-09 00:02:41 +03:00
parent d739ddbd38
commit f13635fb5e
3 changed files with 82 additions and 0 deletions

View File

@@ -169,6 +169,16 @@ static nn_Exit ne_modemBullshit(nn_ModemRequest *req) {
return nn_pushModemMessage(C, req->localAddress, nn_getComputerAddress(C), req->send.port, 0, req->send.contents);
}
if(req->action == NN_MODEM_GETWAKEMESSAGE) {
req->getWake.len = 0;
req->getWake.isFuzzy = false;
return NN_OK;
}
if(req->action == NN_MODEM_SETWAKEMESSAGE) {
return NN_OK;
}
if(C) nn_setError(C, "ne: modem method not implemented");
return NN_EBADCALL;
}

View File

@@ -6929,6 +6929,38 @@ static nn_Exit nn_modemHandler(nn_ComponentRequest *req) {
return e;
}
if(method == NN_MODEMNUM_GETWAKE) {
char buf[NN_MAX_WAKEUPMSG];
mreq.action = NN_MODEM_GETWAKEMESSAGE;
mreq.getWake.buf = buf;
mreq.getWake.len = NN_MAX_WAKEUPMSG;
e = state->handler(&mreq);
if(e) return e;
req->returnCount = 2;
e = mreq.getWake.len == 0 ? nn_pushnull(C) : nn_pushlstring(C, buf, mreq.getWake.len);
if(e) return e;
return nn_pushbool(C, mreq.getWake.isFuzzy);
}
if(method == NN_MODEMNUM_SETWAKE) {
e = nn_defaultstring(C, 0, "");
if(e) return e;
if(nn_checkstring(C, 0, "bad argument #1 (string expected)")) return NN_EBADCALL;
e = nn_defaultboolean(C, 1, false);
if(e) return e;
if(nn_checkboolean(C, 1, "bad argument #2 (boolean expected)")) return NN_EBADCALL;
mreq.action = NN_MODEM_SETWAKEMESSAGE;
mreq.setWake.buf = nn_tolstring(C, 0, &mreq.setWake.len);
if(mreq.setWake.len > NN_MAX_WAKEUPMSG) return NN_ELIMIT;
mreq.setWake.isFuzzy = nn_toboolean(C, 1);
e = state->handler(&mreq);
if(e) return e;
req->returnCount = 1;
return nn_pushbool(C, true);
}
if(C) nn_setError(C, "modem: not implemented yet");
return NN_EBADCALL;
}

View File

@@ -1986,6 +1986,46 @@ typedef struct nn_Tunnel {
extern nn_Tunnel nn_defaultTunnel;
typedef enum nn_TunnelAction {
// tunnel dropped
NN_TUNNEL_DROP,
// gets the channel, result should be pushed to the top of the stack
NN_TUNNEL_GETCHANNEL,
// send/broadcast a message
NN_TUNNEL_SEND,
// returns the wake message
NN_TUNNEL_GETWAKEMESSAGE,
// set the wake message
NN_TUNNEL_SETWAKEMESSAGE,
} nn_TunnelAction;
typedef struct nn_TunnelRequest {
nn_Context *ctx;
nn_Computer *computer;
void *state;
const nn_Tunnel *tunnel;
const char *localAddress;
nn_ModemAction action;
union {
// for send
const nn_EncodedNetworkContents *toSend;
struct {
char *buf;
size_t len;
bool isFuzzy;
} getWake;
struct {
const char *buf;
size_t len;
bool isFuzzy;
} setWake;
};
} nn_TunnelRequest;
typedef nn_Exit (nn_TunnelHandler)(nn_TunnelRequest *req);
nn_Component *nn_createTunnel(nn_Universe *universe, const char *address, const nn_Tunnel *modem, void *state, nn_TunnelHandler *handler);
// Colors and palettes.
// Do note that the