Browse Source

add buffer-transfer support to muxrpc-ipc

Paul Frazee 5 years ago
parent
commit
fadfda353d
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      app/lib/muxrpc-ipc.js

+ 14
- 2
app/lib/muxrpc-ipc.js View File

@@ -22,11 +22,23 @@ module.exports = function (window, sbot, params) {
22 22
   var rpcStream = rpc.createStream()
23 23
   var ipcPush = pushable()
24 24
   ipc.on('muxrpc-ssb', function (e, msg) {
25
-    if (e.sender == window.webContents)
25
+    if (e.sender == window.webContents) {
26
+      if (msg.bvalue) {
27
+        msg.value = new Buffer(msg.bvalue, 'base64')
28
+        delete msg.bvalue
29
+      }
26 30
       ipcPush.push(msg)
31
+    }
27 32
   })
28 33
   pull(ipcPush, rpcStream, pull.drain(
29
-    function (msg) { window.webContents.send('muxrpc-ssb', msg) },
34
+    function (msg) { 
35
+      if (msg.value && Buffer.isBuffer(msg.value)) {
36
+        // convert buffers to base64
37
+        msg.bvalue = msg.value.toString('base64')
38
+        delete msg.value
39
+      }
40
+      window.webContents.send('muxrpc-ssb', msg)
41
+    },
30 42
     function (err) { if (err) { console.error(err) } }
31 43
   ))
32 44
 

Loading…
Cancel
Save