From eead6f9cac46961448d423f9de947021cd613cd3 Mon Sep 17 00:00:00 2001 From: Luciano Iam Date: Sun, 12 Apr 2020 15:58:17 +0200 Subject: [PATCH] WebSockets: make mixer-demo import ardour.js instead of lower level channel.js --- .../builtin/mixer-demo/js/main.js | 23 ++++++++----------- share/web_surfaces/shared/ardour.js | 10 -------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/share/web_surfaces/builtin/mixer-demo/js/main.js b/share/web_surfaces/builtin/mixer-demo/js/main.js index 9a43147529..451f55ac62 100644 --- a/share/web_surfaces/builtin/mixer-demo/js/main.js +++ b/share/web_surfaces/builtin/mixer-demo/js/main.js @@ -16,11 +16,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - // This example does not call the high level API methods in ardour.js - // but interacts directly with the low level message stream instead + // This example does not call the API methods in ardour.js, + // instead it interacts at a lower level by coupling the widgets + // tightly to the message stream import { Message } from '/shared/message.js'; -import { MessageChannel } from '/shared/channel.js'; +import { Ardour } from '/shared/ardour.js'; import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider, StripPanSlider, StripGainSlider, StripMeter } from './widget.js'; @@ -31,13 +32,13 @@ import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider, const FEEDBACK_NODES = ['strip_gain', 'strip_pan', 'strip_meter', 'strip_plugin_enable', 'strip_plugin_param_value']; - const channel = new MessageChannel(location.host); + const ardour = new Ardour(location.host); const widgets = {}; main(); function main () { - channel.messageCallback = (msg) => { + ardour.messageCallback = (msg) => { log(`↙ ${msg}`, 'message-in'); if (msg.node == 'strip_desc') { @@ -53,15 +54,11 @@ import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider, } }; - channel.closeCallback = () => { - log('Connection dropped', 'error'); + ardour.errorCallback = () => { + log('Client error', 'error'); }; - channel.errorCallback = () => { - log('Connection error', 'error'); - }; - - channel.open(); + ardour.open(); } function createStrip (addr, name) { @@ -133,7 +130,7 @@ import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider, function send (widget) { const msg = new Message(widget.node, widget.addr, [widget.value]); log(`↗ ${msg}`, 'message-out'); - channel.send(msg); + ardour.send(msg); } function createElem (html, parent) { diff --git a/share/web_surfaces/shared/ardour.js b/share/web_surfaces/shared/ardour.js index 51712621a7..ce0bb2069b 100644 --- a/share/web_surfaces/shared/ardour.js +++ b/share/web_surfaces/shared/ardour.js @@ -160,13 +160,3 @@ export class Ardour { } } - -async function main() { - const ard = new Ardour(); - ard.errorCallback = (error) => { - alert(error); - }; - await ard.open(); -} - -main();