2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (C) 2017 Konsulko Group
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 import QtWebSockets 1.0
26 property string statusString: "waiting..."
27 property string apiString: "media-manager"
28 property var verbs: []
29 property string payloadLength: "9999"
31 readonly property var msgid: {
38 onTextMessageReceived: {
39 var json = JSON.parse(message)
40 console.debug("Raw response: " + message)
41 var request = json[2].request
42 var response = json[2].response
43 console.debug("response: " + JSON.stringify(response))
48 root.statusString = request.status
49 var verb = verbs.shift()
50 if (verb == "media_added") {
51 console.debug("Media is inserted")
52 } else if (verb == "media_removed") {
53 console.debug("Media is removed")
57 root.statusString = "Bad return value, binding probably not installed"
67 console.debug("onStatusChanged: Open")
70 root.statusString = "WebSocket error: " + root.errorString
75 function sendSocketMessage(verb, parameter) {
76 var requestJson = [ msgid.call, payloadLength, apiString + '/'
78 console.debug("sendSocketMessage: " + JSON.stringify(requestJson))
80 sendTextMessage(JSON.stringify(requestJson))