websockets的bufferedAmount使用范例代码
// 10k max buffer size.
var THRESHOLD = 10240;
 
// Create a New WebSocket connection
var ws = new WebSocket("ws://w3mentor.com");
 
// Listen for the opening event
ws.onopen = function () {
 
   // Attempt to send update every second.
   setInterval( function() {
      // Send only if the buffer is not full
      if (ws.bufferedAmount < THRESHOLD) {
         ws.send(getApplicationState());
      }
   }, 1000);
};




