actor messages now delivered as blobs

This commit is contained in:
2025-06-08 11:06:59 -05:00
parent 8a5f8a4d74
commit 3622a5ec58
4 changed files with 32 additions and 18 deletions

View File

@@ -111,16 +111,23 @@ JSC_CCALL(os_mailbox_push,
if (stop) return JS_UNDEFINED;
}
*/
// void *data = value2wota(js, argv[1], JS_UNDEFINED, NULL);
size_t size;
void *data = js_get_blob_data(js, &size, argv[1]);
void *copy = malloc(size);
memcpy(copy, data, size);
// Create a new blob and copy the data
blob *msg_blob = blob_new(size * 8); // Convert bytes to bits
if (!msg_blob) {
return JS_ThrowInternalError(js, "Could not allocate blob");
}
const char *err = send_message(id, copy);
// Copy data to blob
memcpy(msg_blob->data, data, size);
msg_blob->length = size * 8;
blob_make_stone(msg_blob); // Make it immutable
const char *err = send_message(id, msg_blob);
if (err) {
free(data);
blob_destroy(msg_blob);
return JS_ThrowInternalError(js, "Could not send message: %s", err);
}
)