Awesome Open Source
Awesome Open Source

enter image description here


khan-socket

GitHub license GitHub stars GitHub forks GitHub issues GitHub watchers Whatsapp Donate Paypal Donate Bitcoin


Sistema de websocket para javascript client side ( Websocket system for javascript client side )

Demo: https://chatbotphp.ga/chat


Sempre incluir os arquivos js

  <script src="libs/socket-io.min.js"></script>
  <script src="vendor/khan-socket.min.js"></script>
  • Ou use os CDNS
  <script src="https://rawgit.com/PaulaoDev/khan-socket/master/libs/socket-io.min.js"></script>
  <script src="https://rawgit.com/PaulaoDev/khan-socket/master/vendor/khan-socket.min.js"></script>

Criando o websocket

  var khanSocket = new KhanSocket(io);

Criando canal e enviando algo pelo websocket

  • Para enviar tem que ser um objeto dentro do emit neste caso está sendo enviado uma string para o canal home
  khanSocket.emit({
  	"home": "Olá mundo!!"
  });

Recebendo o websocket

  khanSocket.on('home', function(m){
  	 document.write(m);
  });


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Html (431,634
Real Time (2,665
Javascript Library (1,872
Realtime Messaging (217
Javascript Plugin (146
Related Projects