-
Notifications
You must be signed in to change notification settings - Fork 276
Socket
Tres Finocchiaro edited this page Apr 26, 2021
·
2 revisions
- ✅ 2.1 | ⛔ 2.0 | ⛔ 1.9 | ...
Since 2.1.3
Establish a two-way TCP socket connection using the qz.socket
API.
qz.socket.open('192.168.1.1', '80').then(() => {
console.log("Socket opened");
}).catch(err => {
console.error("An exception occurred opening the socket", err);
});
qz.socket.sendData('192.168.1.1', '80', "some data!").catch(err => {
console.error("An exception occurred sending data to the socket", err);
});
qz.socket.setSocketCallbacks(evt => {
if (evt.type !== 'ERROR') {
console.log('Socket', evt.host, evt.port, 'received response', evt.response);
} else {
console.error(evt.exception);
}
});
qz.socket.close('192.168.1.1', '80').then(() => {
console.log("Socket closed");
}).catch(err => {
console.error("An exception occurred closing the socket", err);
});