Support for Websockets in plugins

Let us know what you would like to see in the next version of this software

Moderator: kfury77

Forum rules
Please follow these guidelines when posting feature requests. This will help to increase the value of your contribution.

  • Do not create new topics for already requested features. Add your comments to the existing feature request topics instead;
  • Create separate topic for each feature suggestion. Do NOT post a number of non-related feature suggestions in a single topic;
  • Give your topic a meaningful title. Do NOT create topics with meaningless titles, such as "My Suggestion" or "My Problem".

Please note that we DO READ all suggestions, even if a reply is not posted. Thanks!

Support for Websockets in plugins

Postby pmk65 » Tue May 30, 2017 1:32 pm

It would be really useful if it was possible to use Websockets for communicating with the 'outside world'.
That way WeBuilder could send/receive data between editor and i.e. nodejs scripts, without having to setup hidden Webkit frames.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Support for Websockets in plugins

Postby pmk65 » Thu Jun 15, 2017 8:03 pm

It would be very similar to how the Webkit/Chromium frame works, and would only require 4 signals/events.
You start by listening for an url/port (similar to how Webkit frame listens for channels)

Signals/Events needed.
1) "onWebsocketOpen" - fired when you make the initial connection and starts listening.
2) "onWebsocketMessage" - fired when data is recieved from the websocket.
3) "onWebsocketClose" - fired when connection is closed.
4) "onWebsocketError" - fired when an error occurs.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Support for Websockets in plugins

Postby Aivars » Fri Jun 16, 2017 12:10 pm

Is this like a built-in on-demand server? Are there any security implications?
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 1989
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Support for Websockets in plugins

Postby pmk65 » Fri Jun 16, 2017 2:27 pm

Websockets is just a communications protocol. It supports CORS.

In JavaScript, you setup a WebSocket CLIENT, like this:
Code: Select all
//create a new WebSocket object.
var websocket = new WebSocket("ws://localhost:7913");

// Events/Signals
websocket.onopen = function(evt) { /* do stuff */ }; //on open event
websocket.onclose = function(evt) { /* do stuff */ }; //on close event
websocket.onmessage = function(evt) { /* do stuff */ }; //on message event
websocket.onerror = function(evt) { /* do stuff */ }; //on error event

// Methods
websocket.send(message); //send method
websocket.close(); //close method


This allows bidirectional communication between the client and a (node.js) Push server located at "localhost:7913"

The server can then process data send using the "send()" method. And return the result asynchronously, triggering the "onmessage" siggnal at the client.


Some useful links for more information.
http://codular.com/node-web-sockets
https://www.html5rocks.com/en/tutorials/websockets/basics/
https://www.tutorialspoint.com/websockets/index.htm

Node.js WebSocket library:
https://github.com/websockets/ws
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 359
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark


Return to HTMLPad / Rapid CSS / Rapid PHP / WeBuilder Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron