Chat application AJAX polling

前端 未结 12 1618
天命终不由人
天命终不由人 2020-12-14 20:11

In the project I am currently working on, we have the need to develop a web chat application, not a very complex chat, just a way to connect two people to talk about a very

12条回答
  •  [愿得一人]
    2020-12-14 20:50

    I did this very same thing a few months back and had fun just playing around with the concepts. I actually used the forever-frame technique instead of polling.

    The below code is my "comet" js file that contains the general concepts required to get a "party chat" setup.

    function Comet(key) {
    
      var random = key;
      var title = 'Comet';
      var connection = false;
      var iframediv = false;
      var browserIsIE = /*@cc_on!@*/false;
      var blurStatus = false;
      var tmpframe = document.createElement('iframe');
      var nl = '\r\n';
    
      this.initialize = function() {
        if (browserIsIE) {
          connection = new ActiveXObject("htmlfile");
          connection.open();
          connection.write("");
          connection.write("
    
                                     
                  
提交回复
热议问题