serialize IPC to avoid duplicate reference nulling

This commit is contained in:
Paul Frazee 2015-07-10 14:56:32 -05:00
parent bfc579a584
commit d32f7b52a6

View File

@ -26,6 +26,12 @@ module.exports = function (window, sbot, params) {
var ipcPush = pushable() var ipcPush = pushable()
ipc.on('muxrpc-ssb', function (e, msg) { ipc.on('muxrpc-ssb', function (e, msg) {
if (e.sender == window.webContents) { if (e.sender == window.webContents) {
try {
if (typeof msg == 'string')
msg = JSON.parse(msg)
} catch (e) {
return
}
if (msg.bvalue) { if (msg.bvalue) {
msg.value = new Buffer(msg.bvalue, 'base64') msg.value = new Buffer(msg.bvalue, 'base64')
delete msg.bvalue delete msg.bvalue
@ -40,7 +46,7 @@ module.exports = function (window, sbot, params) {
msg.bvalue = msg.value.toString('base64') msg.bvalue = msg.value.toString('base64')
delete msg.value delete msg.value
} }
window.webContents.send('muxrpc-ssb', msg) window.webContents.send('muxrpc-ssb', JSON.stringify(msg))
}, },
function (err) { if (err) { console.error(err) } } function (err) { if (err) { console.error(err) } }
)) ))