/poorws

Primary LanguageJavaScriptMIT LicenseMIT

poorws.js

This is a very simple WebSocket Client wrapper.

usage

initialization

<script src="js/poorws.js"></script>
var ws = new poorws("SERVER URL");

handle on connection status changed

ws.onStatusChange = function(status){
	$("#status").text(status);
};

send

$("#sendmes").click(function(){
	ws.send("testes");
});

onMessage

ws.onMessage = function(mes){
	var str = JSON.parse(mes.data);
	console.log(str);
};

That's all! Enjoy! :D