mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
send realtime data events as int array instead of base64
This commit is contained in:
@@ -365,8 +365,11 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
callJavaScriptFunction("__webxdcUpdate()");
|
||||
} else if ((eventId == DcContext.DC_EVENT_WEBXDC_REALTIME_DATA && event.getData1Int() == dcAppMsg.getId())) {
|
||||
Log.i(TAG, "handling realtime data event");
|
||||
String base64 = Base64.encodeToString(event.getData2Blob(), Base64.NO_WRAP | Base64.NO_PADDING);
|
||||
callJavaScriptFunction("__webxdcRealtimeData(\"" + base64 + "\")");
|
||||
StringBuilder data = new StringBuilder();
|
||||
for (byte b : event.getData2Blob()) {
|
||||
data.append(((int) b) + ",");
|
||||
}
|
||||
callJavaScriptFunction("__webxdcRealtimeData([" + data + "])");
|
||||
} else if ((eventId == DcContext.DC_EVENT_MSGS_CHANGED && event.getData2Int() == dcAppMsg.getId())) {
|
||||
this.dcAppMsg = this.dcContext.getMsg(event.getData2Int()); // msg changed, reload data from db
|
||||
Util.runOnAnyBackgroundThread(() -> {
|
||||
|
||||
@@ -16,10 +16,9 @@ window.webxdc = (() => {
|
||||
}
|
||||
};
|
||||
|
||||
window.__webxdcRealtimeData = (base64Data) => {
|
||||
window.__webxdcRealtimeData = (intArray) => {
|
||||
if (realtimeChannel) {
|
||||
const data = Uint8Array.from(atob(base64Data), (m) => m.codePointAt(0));
|
||||
realtimeChannel.__receive(data);
|
||||
realtimeChannel.__receive(Uint8Array.from(intArray));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user