actor messages now delivered as blobs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user