Skip to content

Web Sockets

Arturo Vasquez edited this page Apr 18, 2021 · 2 revisions

To work with Web Socket

get the Web Workers API interface

   let wsapi=genrl.ws;

Set the Web Socket

   wsapi.set('socket1',"ws://127.0.0.1:5001");

Send a Message to Web Socket

	g("#btnwebsock").click(function(){
		genrl.log("Mensaje a enviar " + g("#mensaje").val());
		wsapi.reply('socket1',g("#mensaje").val(),function(){
			g("#responsechat").append(g("#mensaje").val());
		});
	});

How to receive DATA from Web Socket:

wsapi.receive('socket1',function(data){
     g("#responsechat").append(data);
});

Search into the pages for more info

Clone this wiki locally