13
0

WebSockets: rename Channel to ArdourMessageChannel

This commit is contained in:
Luciano Iam 2020-04-11 17:49:34 +02:00 committed by Robin Gareus
parent 02cdd5b52d
commit 5c78c85ef5
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 30 additions and 25 deletions

View File

@ -16,7 +16,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
import { Channel } from '/shared/channel.js'; import { ArdourMessageChannel } from '/shared/channel.js';
import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider, import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider,
StripPanSlider, StripGainSlider, StripMeter } from './widget.js'; StripPanSlider, StripGainSlider, StripMeter } from './widget.js';
@ -26,34 +27,38 @@ import { Switch, DiscreteSlider, ContinuousSlider, LogarithmicSlider,
const FEEDBACK_NODES = ['strip_gain', 'strip_pan', 'strip_meter', 'strip_plugin_enable', const FEEDBACK_NODES = ['strip_gain', 'strip_pan', 'strip_meter', 'strip_plugin_enable',
'strip_plugin_param_value']; 'strip_plugin_param_value'];
const channel = new Channel(location.host); const channel = new ArdourMessageChannel(location.host);
const widgets = {}; const widgets = {};
channel.messageCallback = (node, addr, val) => { main();
log(`${node} (${addr}) = ${val}`, 'message-in');
if (node == 'strip_desc') { function main () {
createStrip (addr, ...val); channel.messageCallback = (node, addr, val) => {
} else if (node == 'strip_plugin_desc') { log(`${node} (${addr}) = ${val}`, 'message-in');
createStripPlugin (addr, ...val);
} else if (node == 'strip_plugin_param_desc') { if (node == 'strip_desc') {
createStripPluginParam (addr, ...val); createStrip (addr, ...val);
} else if (FEEDBACK_NODES.includes(node)) { } else if (node == 'strip_plugin_desc') {
if (widgets[[node, addr]]) { createStripPlugin (addr, ...val);
widgets[[node, addr]].value = val[0]; } else if (node == 'strip_plugin_param_desc') {
createStripPluginParam (addr, ...val);
} else if (FEEDBACK_NODES.includes(node)) {
if (widgets[[node, addr]]) {
widgets[[node, addr]].value = val[0];
}
} }
} };
};
channel.closeCallback = () => { channel.closeCallback = () => {
log('Connection dropped', 'error'); log('Connection dropped', 'error');
}; };
channel.errorCallback = () => { channel.errorCallback = () => {
log('Connection error', 'error'); log('Connection error', 'error');
}; };
channel.open(); channel.open();
}
function createStrip (addr, name) { function createStrip (addr, name) {
const id = `strip-${addr[0]}`; const id = `strip-${addr[0]}`;

View File

@ -16,12 +16,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
import { Channel } from './channel.js'; import { ArdourMessageChannel } from './channel.js';
export class Ardour { export class Ardour {
constructor () { constructor () {
this.channel = new Channel(location.host); this.channel = new ArdourMessageChannel(location.host);
} }
async open () { async open () {

View File

@ -18,7 +18,7 @@
const JSON_INF = 1.0e+128; const JSON_INF = 1.0e+128;
export class Channel { export class ArdourMessageChannel {
constructor (host) { constructor (host) {
// https://developer.mozilla.org/en-US/docs/Web/API/URL/host // https://developer.mozilla.org/en-US/docs/Web/API/URL/host