Closed Vallevard closed 6 years ago
Hi @Vallevard, currently no. Now Total.js can communicate with client-side only, but I have a plan to create a client for WebSocket on server-side.
Trust me, here is my first implementation: https://github.com/totaljs/framework/blob/v2.8.1/websocketclient.js
HI @Vallevard,
I have a good message, I have implemented WebSocket client successfully into the framework. If you want to test it - install beta version of Total.js $ npm install total.js@beta
.
How does it work?
require('total.js');
WEBSOCKETCLIENT(function(client) {
client.connect('ws://127.0.0.1:8000/');
client.on('open', function() {
console.log('OPEN');
});
client.on('close', function() {
console.log('CLOSE');
});
client.on('message', function(message) {
console.log('MESSAGE', message);
});
// Default options:
// client.options.type = 'json';
// client.options.compress = true;
// client.options.reconnect = 3000;
// client.options.encodedecode = true;
// Sending:
// client.send({ some: 'object' });
});
Hello, It is possible to communicate via sockets between different web apps(both server side), like socket.io and socket.io-client.
Regards.