baconbrad / php-webkit

PHP-Webkit is a boilerplate that allows you to package and run PHP applications within a NW.js (formally node-webkit) project.
Other
88 stars 29 forks source link

How can I pass something from php-webkit/main.js to application/index.php #28

Closed visualbadger closed 7 years ago

visualbadger commented 7 years ago

Is any possibility to pass data from main.js to application/index.php ? I have a little project that requires arduino and I use serialport in main.js to take data from arduino and with socket.io I want to emit that data to application/index.php .

This is my socket.io test function in main.js

var io = require('socket.io').listen(server);
function sendTime() {
    io.emit('time', { time: new Date().toJSON() });
}
setInterval(sendTime, 100);

This is my function from index.php:

socket.on('time', function(data) {
console.log(data.time);
});
baconbrad commented 7 years ago

You are going to have to look into a standard AJAX solution more than likely. Your NW.js app is the client running a server. So you basically need to have that client pass data to the server.