From f417e58d71ee256b42a59f4ffa8fe21389e73af3 Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Fri, 1 Apr 2016 20:28:38 +0200 Subject: websocket test (breaking commit) diff --git a/www/js/apps.js b/www/js/apps.js index dd5b337..945b454 100644 --- a/www/js/apps.js +++ b/www/js/apps.js @@ -105,12 +105,13 @@ function apps_select(app) { } function apps_init() { - importer = new Rdxport.Importer(); apps_current = locationHrefValue(); if(auth_token && auth_username) { // todo: do this at a central place + importer = new Rdxport.Importer(auth_username, auth_token); + rdxport = new Rdxport.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi'); @@ -121,6 +122,8 @@ function apps_init() { $(window).on('popstate', function(event) { if(auth_token && auth_username) { // todo: do this at a central place + importer = new Rdxport.Importer(auth_username, auth_token); + rdxport = new Rdxport.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi'); diff --git a/www/js/auth.js b/www/js/auth.js index d01b70d..dd21e39 100644 --- a/www/js/auth.js +++ b/www/js/auth.js @@ -39,6 +39,8 @@ function auth_loginSuccess(data) { sessionStorage.setItem("auth_token", auth_token); // todo: do this at a central place + importer = new Rdxport.Importer(auth_username, auth_token); + rdxport = new Rdxport.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi'); diff --git a/www/js/importer.js b/www/js/importer.js index 4ea55b3..96c7dac 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -24,10 +24,88 @@ var Rdxport = Rdxport || {}; -Rdxport.Importer = function() { - this.$el = $('#uploadModal'); +Rdxport.Importer = function(username, token) { + this.username = username; + this.token = token; + this.$el = $('#uploadModal'); this.uploads = []; + this.webSocket = null; + + this.initWebSocket(); +}; + +Rdxport.Importer.CMD_LIST = 'list'; +Rdxport.Importer.CMD_NEW = 'new'; +Rdxport.Importer.CMD_RECONNECT = 'reconnect'; + +Rdxport.Importer.prototype.initWebSocket = function() { + var importer = this; + + var webSocket = new WebSocket('wss://import.helsinki.at/rhimportd'); + + webSocket.onclose = function(code, reason) { + console.log('close'); + console.log(code); + console.log(reason); + }; + + webSocket.onerror = function() { + console.log('error'); + }; + + webSocket.onopen = function() { + console.log('open'); + + console.log('send list'); + var sendOptions = { + COMMAND: Rdxport.Importer.CMD_NEW, + LOGIN_NAME: importer.username, + PASSWORD: importer.token, + TIMEOUT: 200, + REFERENCE_ID: 999, + SHOW_ID: 10000, + CLEAR_SHOW_CARTS: true, + SOURCE_URI: 'archiv://2016/03/31/05/00' + }; + console.log(sendOptions); + this.send(JSON.stringify(sendOptions)); + }; + + webSocket.onmessage = function(event) { + console.log('message'); + console.log(event.data); + }; + + /*this.webSocket = new WebSocket('wss://import.helsinki.at/rhimportd'); + + this.webSocket.onclose = function(code, reason) { + console.log('close'); + console.log(code); + console.log(reason); + }; + + this.webSocket.onerror = function() { + console.log('error'); + }; + + this.webSocket.onopen = function() { + console.log('open'); + + console.log('send reconnect'); + var reconnectOptions = { + COMMAND: Rdxport.Importer.CMD_RECONNECT, + LOGIN_NAME: importer.username, + PASSWORD: importer.token + }; + console.log(reconnectOptions); + this.send(JSON.stringify(reconnectOptions)); + }; + + this.webSocket.onmessage = function(event) { + console.log('message'); + console.log(event.data); + };*/ }; Rdxport.Importer.prototype.resetModal = function() { -- cgit v0.10.2 From 7eed6d7aa3bb7b0ee22fa3cf310976cfbeaf46b8 Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Wed, 13 Apr 2016 18:28:02 +0200 Subject: fix websocket archiv source format diff --git a/contrib/Pflichtenheft-Peter.md b/contrib/Pflichtenheft-Peter.md index 74362b8..1cbc487 100644 --- a/contrib/Pflichtenheft-Peter.md +++ b/contrib/Pflichtenheft-Peter.md @@ -59,7 +59,7 @@ Es ist ein Interface zu entwickeln, mit dessen Hilfe die Zuweisung der Musikpool Es soll möglich sein Dateien direkt aus verschiednen exteren Quellen zu importieren. Zu diesem Zweck gibt es serverseitig die Komponente `rhimportd`. Diese wird über eine Websocket-API gesteuert und kümmert sich um den tatsächlichen Import. `rhwebimport` initiiert den Import und visualisiert den Fortschritt. Ausserdem soll es möglich sein den Fortschritt etwaiger laufender Import-Prozesse nach einem erneuten Einloggen (zb. nach einem Verbindungsabbruch) weiter anzuzeigen. `rhimportd` bietet alle dafür notwendigen API Funktionen. Sollten zu diese Zweck Änderungen an der API notwendig sein sollen diese gemeinsam mit dem Radio Helsinki Technik-Team erarbeitet werden. Die Änderungen an `rhimportd` werden von Radio Helsinki erledigt. Folgende externe Quellen sollen unterstützt werden: - - archiv://YYYY/MM/DD/hh/00 - import aus dem Sendungsarchiv von Radio Helsinki (immer volle Stunden) + - archiv://YYYY/MM/DD/hh - import aus dem Sendungsarchiv von Radio Helsinki (immer volle Stunden) - http://, https://, ftp://, ftps:// - import von der entsprechenden URL ### zustätliche Importquelle: `public:///` diff --git a/www/js/importer.js b/www/js/importer.js index 96c7dac..6803921 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -63,10 +63,10 @@ Rdxport.Importer.prototype.initWebSocket = function() { LOGIN_NAME: importer.username, PASSWORD: importer.token, TIMEOUT: 200, - REFERENCE_ID: 999, + REFERENCE_ID: "999", SHOW_ID: 10000, CLEAR_SHOW_CARTS: true, - SOURCE_URI: 'archiv://2016/03/31/05/00' + SOURCE_URI: 'archiv://2016/03/31/05' }; console.log(sendOptions); this.send(JSON.stringify(sendOptions)); -- cgit v0.10.2