summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/helsinki.at/rhimportd/ctrlWebSocket.go10
-rw-r--r--test/socket.html47
2 files changed, 36 insertions, 21 deletions
diff --git a/src/helsinki.at/rhimportd/ctrlWebSocket.go b/src/helsinki.at/rhimportd/ctrlWebSocket.go
index 4c1bf45..7ceb9c4 100644
--- a/src/helsinki.at/rhimportd/ctrlWebSocket.go
+++ b/src/helsinki.at/rhimportd/ctrlWebSocket.go
@@ -110,7 +110,7 @@ func sendWebSocketResponse(ws *websocket.Conn, rd interface{}) {
func sendWebSocketErrorResponse(ws *websocket.Conn, code int, err_str string) {
rd := &webSocketResponseBaseData{}
rd.ResponseCode = code
- rd.Type = "ERROR"
+ rd.Type = "error"
rd.ErrorString = err_str
sendWebSocketResponse(ws, rd)
}
@@ -118,7 +118,7 @@ func sendWebSocketErrorResponse(ws *websocket.Conn, code int, err_str string) {
func sendWebSocketAckResponse(ws *websocket.Conn, code int, id, refid string) {
rd := &webSocketResponseBaseData{}
rd.ResponseCode = code
- rd.Type = "ACK"
+ rd.Type = "ack"
rd.ErrorString = "OK"
rd.Id = id
rd.RefId = refid
@@ -128,7 +128,7 @@ func sendWebSocketAckResponse(ws *websocket.Conn, code int, id, refid string) {
func sendWebSocketListResponse(ws *websocket.Conn, sessions map[string]string) {
rd := &webSocketResponseListData{}
rd.ResponseCode = http.StatusOK
- rd.Type = "LIST"
+ rd.Type = "list"
rd.ErrorString = "OK"
rd.Sessions = sessions
sendWebSocketResponse(ws, rd)
@@ -137,7 +137,7 @@ func sendWebSocketListResponse(ws *websocket.Conn, sessions map[string]string) {
func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step int, step_name string, progress float64) {
rd := &webSocketResponseProgressData{}
rd.ResponseCode = http.StatusOK
- rd.Type = "PROGRESS"
+ rd.Type = "progress"
rd.ErrorString = "OK"
rd.Id = id
rd.RefId = refid
@@ -150,7 +150,7 @@ func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step in
func sendWebSocketDoneResponse(ws *websocket.Conn, code int, err_str, id, refid string, cart, cut uint) {
rd := &webSocketResponseDoneData{}
rd.ResponseCode = code
- rd.Type = "DONE"
+ rd.Type = "done"
rd.ErrorString = err_str
rd.Id = id
rd.RefId = refid
diff --git a/test/socket.html b/test/socket.html
index a7504f8..4d26667 100644
--- a/test/socket.html
+++ b/test/socket.html
@@ -16,6 +16,10 @@
margin-top: 1em;
margin-bottom: 1em;
}
+
+ td {
+ text-align: right;
+ }
</style>
<script src="jquery.min.js"></script>
<script type="text/javascript">
@@ -38,8 +42,8 @@
function list() {
req = { COMMAND: "list",
- LOGIN_NAME: "heslinki",
- PASSWORD: "12423" };
+ LOGIN_NAME: $('#username').val(),
+ PASSWORD: $('#token').val()};
sl = new SessionList(req);
}
@@ -52,14 +56,14 @@
$('#rawmsg').append(event.data + "\n");
msg = $.parseJSON(event.data)
switch (msg.TYPE) {
- case "ACK":
+ case "ack":
$('#sessionid').val(msg.ID);
$('#buttonrun').attr('disabled','disabled')
$('#buttonreconnect').attr('disabled','disabled')
$('#buttoncancel').removeAttr('disabled')
break;
- case "DONE":
- case "ERROR":
+ case "done":
+ case "error":
this.sock.close();
init();
break;
@@ -83,8 +87,8 @@
req = { COMMAND: "new",
TIMEOUT: 200,
REFERENCE_ID: "my-very-personal-import",
- LOGIN_NAME: "heslinki",
- PASSWORD: "12423",
+ LOGIN_NAME: $('#username').val(),
+ PASSWORD: $('#token').val(),
SHOW_ID: 10002,
CLEAR_SHOW_CARTS: true,
SOURCE_URI: "fake://10000" };
@@ -93,7 +97,7 @@
function reconnect() {
req = { COMMAND: "reconnect",
- LOGIN_NAME: "heslinki",
+ LOGIN_NAME: $('#username').val(),
ID: $('#sessionid').val() };
s = new Session(req);
}
@@ -114,13 +118,24 @@
<h1>Radio Helsinki Rivendell Importer:</h1>
- <button id="buttonlist" onclick="list()">list</button>
- <div id="listmsg" class="data"></div>
-
- <button id="buttonrun" onclick="run()">start</button>
- <input id="sessionid" type="text" size="45" label="ID">
- <button id="buttonreconnect" onclick="reconnect()">reconnect</button>
- <button id="buttoncancel" onclick="cancel()">cancel</button>
- <div id="rawmsg" class="data"></div>
+ <p>
+ <table>
+ <tr><td>Username</td><td><input id="username" type="text" size="20" value="heslinki"></td></tr>
+ <tr><td>Token</td><td><input id="token" type="text" size="20"></td></tr>
+ </table>
+ </p>
+
+ <p>
+ <button id="buttonlist" onclick="list()">list</button>
+ <div id="listmsg" class="data"></div>
+ </p>
+
+ <p>
+ <button id="buttonrun" onclick="run()">start</button>
+ <input id="sessionid" type="text" size="45">
+ <button id="buttonreconnect" onclick="reconnect()">reconnect</button>
+ <button id="buttoncancel" onclick="cancel()">cancel</button>
+ <div id="rawmsg" class="data"></div>
+ </p>
</body>
</html>