This commit is contained in:
John Smith
2023-06-16 11:57:55 -04:00
parent d114ea3b72
commit 14ba85efda
18 changed files with 158 additions and 75 deletions
+3 -3
View File
@@ -1560,12 +1560,12 @@ class VeilidFFI implements Veilid {
}
@override
Future<void> appCallReply(String id, Uint8List message) {
final nativeId = id.toNativeUtf8();
Future<void> appCallReply(String call_id, Uint8List message) {
final nativeCallId = call_id.toNativeUtf8();
final nativeEncodedMessage = base64UrlNoPadEncode(message).toNativeUtf8();
final recvPort = ReceivePort("app_call_reply");
final sendPort = recvPort.sendPort;
_appCallReply(sendPort.nativePort, nativeId, nativeEncodedMessage);
_appCallReply(sendPort.nativePort, nativeCallId, nativeEncodedMessage);
return processFutureVoid(recvPort.first);
}
+2 -2
View File
@@ -580,10 +580,10 @@ class VeilidJS implements Veilid {
}
@override
Future<void> appCallReply(String id, Uint8List message) {
Future<void> appCallReply(String callId, Uint8List message) {
var encodedMessage = base64UrlNoPadEncode(message);
return _wrapApiPromise(
js_util.callMethod(wasm, "app_call_reply", [id, encodedMessage]));
js_util.callMethod(wasm, "app_call_reply", [callId, encodedMessage]));
}
@override
+7 -5
View File
@@ -262,7 +262,9 @@ abstract class VeilidUpdate {
case "AppCall":
{
return VeilidAppCall(
sender: json["sender"], message: json["message"], id: json["id"]);
sender: json["sender"],
message: json["message"],
callId: json["call_id"]);
}
case "Attachment":
{
@@ -348,22 +350,22 @@ class VeilidAppMessage implements VeilidUpdate {
class VeilidAppCall implements VeilidUpdate {
final String? sender;
final Uint8List message;
final String id;
final String callId;
//
VeilidAppCall({
required this.sender,
required this.message,
required this.id,
required this.callId,
});
@override
Map<String, dynamic> toJson() {
return {
'kind': "AppMessage",
'kind': "AppCall",
'sender': sender,
'message': base64UrlNoPadEncode(message),
'id': id,
'call_id': callId,
};
}
}
+5 -5
View File
@@ -707,21 +707,21 @@ pub extern "C" fn release_private_route(port: i64, route_id: FfiStr) {
}
#[no_mangle]
pub extern "C" fn app_call_reply(port: i64, id: FfiStr, message: FfiStr) {
let id = id.into_opt_string().unwrap_or_default();
pub extern "C" fn app_call_reply(port: i64, call_id: FfiStr, message: FfiStr) {
let call_id = call_id.into_opt_string().unwrap_or_default();
let message = message.into_opt_string().unwrap_or_default();
DartIsolateWrapper::new(port).spawn_result(async move {
let id = match id.parse() {
let call_id = match call_id.parse() {
Ok(v) => v,
Err(e) => {
return APIResult::Err(veilid_core::VeilidAPIError::invalid_argument(e, "id", id))
return APIResult::Err(veilid_core::VeilidAPIError::invalid_argument(e, "call_id", call_id))
}
};
let message = data_encoding::BASE64URL_NOPAD
.decode(message.as_bytes())
.map_err(|e| veilid_core::VeilidAPIError::invalid_argument(e, "message", message))?;
let veilid_api = get_veilid_api().await?;
veilid_api.app_call_reply(id, message).await?;
veilid_api.app_call_reply(call_id, message).await?;
APIRESULT_VOID
});
}