HTML5

11. Bölüm : HTML5 Web Sockets

Pooling
Pooling Diagramı
Pooling
Piggyback Pooling
Piggyback Pooling Diagramı
Piggyback Pooling
Comet
Comet Diagramı
Comet
Web Socketleri Pooling Karşılaştırması
Web Socketleri Pooling Karşılaştırması
Web Socketleri Pooling Karşılaştırması
Web Socketleri Demo Web Socket İstemcisi 1

Mesaj :

Mesajlar :

Durum : Sunucuya Bağlı Değil.
Web Socketleri Demo Kodları

Html :

<button onclick="connect();">Web Socket Sunucusuna Bağlan</button>
Mesaj : <input type=text id=txtMessage />
<button onclick="sendMessage();">Gönder</button>

JavaScript :

var connection;

function connect() {
   if (typeof WebSocket != undefined) {
      connection = new WebSocket('ws://node.remysharp.com:8001');
      connection.onmessage = function (event) {
         document.getElementById("divSockets").innerHTML += 'Onlar : ' + event.data;
      }
   }
}

function sendMessage() {
   if (connection!= null && connection.readyState === 1) {
      var message = document.getElementById('txtMessage').value;
      connection.send(message);
      document.getElementById("divSockets").innerHTML += 'Biz :' + message;
      document.getElementById('txtMessage').value = '';
   } else {
      document.getElementById("divSockets").innerHTML += 'Sunucu Bağlantısı Yok!';
   }
}