Post 2 made on Tuesday January 19, 2021 at 11:26 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,994 |
|
|
Tom,
The first issue you will have is that you have 2 different scripts that use the same variable names: result and socket.
In order for you to be able to combine these, you'll need to modify the names.
The easiest is to change the 2 variable names in Script 1.
var socket1 = new TCPSocket(false); var result1="";
var JSON_on='{"on":true}';
function getInfos(commands) { socket1.write('PUT /api/lVfthQzyz9ZbNsUyndnZT9WBBOQ852HY3fEcPUVg/groups/1/action HTTP/1.1\r\nHost: 10.0.0.2\r\nUser-Agent: ProntoTSU9600\r\nContent-Length: '+commands.length+'\r\n\r\n'+commands);
}
socket1.onConnect = function() { getInfos(JSON_on); };
socket1.onData = function() {
};
socket1.onClose = function() { socket1 = null }
socket1.onIOerror = function() { System.print("error"); try { socket1.close() socket1 = null } catch(e) {} }
socket1.connect('10.0.0.2', 80, 3000);
After you do this, you should be able to put the content of both scripts into the same page or activity script.
|
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|