OK, I think I may have an understanding. So the question is where would I put this, for I am amusing I can not open and close two sockets and write to two sockets all in the same function.
so this is my script so far,
var url = CF.widget("Kodi_aURL","Kodi_PARAMETERS_test").label;
var info;
var FFcommand = "2";
var RRcommand = "2";
function kodi1(){
var socket = new TCPSocket();
socket.onConnect = function() {
prefix = 'GET /jsonrpc?request={"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "thumbnail"], "playerid": 1 }, "id": "1"}'
postfix = ' HTTP/1.0\r\n'
try {
socket.write(prefix+postfix);
socket.write("HOST:+url+\r\n\r\n");
} catch(e) {
socket.close()
}}
socket.onData = function() {
info1 = socket.read();
if (info1.indexOf('unknown') !== -1) {
CF.widget("KODI_TITLE").label="Nothing Playing";
}else{
var title = info1.split('title":"').pop().split('","type')[0];
CF.widget("KODI_TITLE").label=title;
}
socket.close()
}
socket.onIOError = function(e) {
socket.close()
}
socket.connect(url, 9090, 3000);
};
Last edited by mpg7321 on August 5, 2020 19:06.