From 3feb310fc45a10403e6b41b0ed1a0701036ee2a5 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 15 May 2019 14:52:58 +0200 Subject: [PATCH] Add mailbox inner channel --- www/common/cryptpad-common.js | 8 ++++++++ www/common/outer/mailbox.js | 35 +++++++++++++++++++++++++++++++++++ www/common/outer/store-rpc.js | 2 ++ 3 files changed, 45 insertions(+) create mode 100644 www/common/outer/mailbox.js diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 9f1d3f544..027b61929 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -656,6 +656,12 @@ define([ }; cursor.onEvent = Util.mkEvent(); + // Mailbox + var mailbox = common.mailbox = {}; + mailbox.execCommand = function (data, cb) { + postMessage("MAILBOX_COMMAND", data, cb); + }; + mailbox.onEvent = Util.mkEvent(); // Pad RPC var pad = common.padRpc = {}; @@ -1096,6 +1102,8 @@ define([ CHAT_EVENT: common.messenger.onEvent.fire, // Cursor CURSOR_EVENT: common.cursor.onEvent.fire, + // Mailbox + MAILBOX_EVENT: common.mailbox.onEvent.fire, // Pad PAD_READY: common.padRpc.onReadyEvent.fire, PAD_MESSAGE: common.padRpc.onMessageEvent.fire, diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js new file mode 100644 index 000000000..ab9d24d58 --- /dev/null +++ b/www/common/outer/mailbox.js @@ -0,0 +1,35 @@ +define([ + '/common/common-util.js', + '/common/common-constants.js', + '/customize/messages.js', + '/bower_components/chainpad-netflux/chainpad-netflux.js', + '/bower_components/chainpad-crypto/crypto.js', +], function (Util, Constants, Messages, CpNetflux, Crypto) { + var Mailbox = {}; + + Mailbox.init = function (store, waitFor, emit) { + var mailbox = {}; + var ctx = { + store: store, + emit: emit, + }; + + mailbox.removeClient = function (clientId) { + // TODO + //removeClient(ctx, clientId); + }; + mailbox.leavePad = function (padChan) { + // TODO + //leaveChannel(ctx, padChan); + }; + mailbox.execCommand = function (clientId, obj, cb) { + var cmd = obj.cmd; + var data = obj.data; + }; + + return mailbox; + }; + + return Mailbox; +}); + diff --git a/www/common/outer/store-rpc.js b/www/common/outer/store-rpc.js index 49bb7c960..aed0d5ab4 100644 --- a/www/common/outer/store-rpc.js +++ b/www/common/outer/store-rpc.js @@ -66,6 +66,8 @@ define([ OO_COMMAND: Store.onlyoffice.execCommand, // Cursor CURSOR_COMMAND: Store.cursor.execCommand, + // Mailbox + MAILBOX_COMMAND: Store.mailbox.execCommand, // Pad SEND_PAD_MSG: Store.sendPadMsg, JOIN_PAD: Store.joinPad,