It took 10 sec delay to receive message on web page that websocket server "connection closed", I need faster update about server connection.

Jan 22, 2015 at 8:20 PM
Hi

I have developed a basic console web application using SuperWebSocket. When one runs it on web browser,it shows three buttons
-Connect
-Disconnect
-Send
Initially when I tried connect and disconnect operations,It was updating connection status(Connection open or connection close) to user on web browser immediately.

I have done data transfer between Web app and WebSocket server,but after closing connection, it took 10 sec to update user that "Connection closed". I want to show this "Connection closed" message as soon as data transmission is finished without any delay.
Following is the code for webapp................open for all kind of suggessions and modifications
Thanks in advance.

CODE

<!DOCTYPE html> <!--damit spezifiziere ich den HTML-Sprachstandard 5 als den Standard, an den ich in der meiner HTML-Datei halte -->
<html>
<head>
<meta charset="UTF-8"> <!-- kodierungsart doit etre ds les premiers 1024 byte-->
<title>lol</title> <!--ce titre apparait ds la description de la fenêtre -->        
    <link rel="stylesheet" type="text/css" href="style.css" /> 
    <link rel="stylesheet" type="text/css" href="style1.css" />
 <script type="text/javascript" src="jquery.js"></script>
 <script type="text/javascript">
  var noSupportMessage = "Your browser cannot support WebSocket!";
  var ws;
  function appendMessage(message) {
   $('#serverStatus').append(message);             
        }                   
   function connectSocketServer() {
   var support = "MozWebSocket" in window ? 'MozWebSocket' : ("WebSocket" in window ? 'WebSocket' : null);  
    if (support == null) {
    appendMessage("* " + noSupportMessage + "<br/>");
    return;
       }

    appendMessage("* Connecting to server ..<br/>");               
     ws = new window[support]('ws://192.168.1.10:2013/');
            ws.onmessage = function (evt) {
            var donnees = evt.data
            var results = donnees.split('$');
            for (var j = 0; j < 10; j++) {
             var result = results[j].split(';');
              switch (result[0]) {
                        case "Z1":
                            {
             for (var i = 1; i < result.length; i++) {
            var tabdaten = document.getElementById("Z1" + (i - 1)).innerHTML = (result[i]);
               }
               }
              break;
     case "Z2":
                            {
              for (var i = 1; i < result.length; i++) {
              var tabdaten = document.getElementById("Z2" + (i - 1)).innerHTML = (result[i]);
                }
                }
                break;                          
                        default:
                    }
                }

            };



            // when the connection is established, this method is called
            ws.onopen = function () {
                appendMessage('* Connection open<br/>');
                $('#pswd').attr("disabled", "");
                $('#sendButton').attr("disabled", "");
                $('#connectButton').attr("disabled", "disabled");
                $('#disconnectButton').attr("disabled", "");
            };

            // when the connection is closed, this method is called
            ws.onclose = function () {
                appendMessage('* Connection closed<br/>');
                $('#pswd').attr("disabled", "disabled");
                $('#sendButton').attr("disabled", "disabled");
                $('#connectButton').attr("disabled", "");
                $('#disconnectButton').attr("disabled", "disabled");
            }

          }

        function sendMessage() {
            if (ws) {
                var messageBox = document.getElementById('pswd');
                ws.send(messageBox.value);
                messageBox.value = "";
            }
        } 

        function disconnectWebSocket() {
            if (ws) {
                ws.close();
            }
        }

        function connectWebSocket() {
            connectSocketServer();
        }

        window.onload = function () {
            $('#pswd').attr("disabled", "disabled");
            $('#sendButton').attr("disabled", "disabled");
            $('#disconnectButton').attr("disabled", "disabled");
        }

    </script>
</head>

<body>
    <!-- page start -->     
    <div id="pageeins">
    <!-- header start -->   
        <div data-role="header">
            <img src="logo_lol.png" alt="text">
        </div>
        <!-- header end-->

        <!-- content start -->
        <div data-role="main" class="ui-content" id="content">
            <div id="content1">
                <p>Projekt:Automation-Meets-Science</p>
                <p>Maschine:100202</p>
                <div class="ui-grid-a">

                    <div class="ui-block-a">
                     <input type="button" id="connectButton" value="connect" onclick="connectWebSocket()" />
                    </div>

                    <div class="ui-block-b">
                     <input type="button" id="disconnectButton" value="disconnect" onclick="disconnectWebSocket()" />
                    </div>
                </div>
                <div class="ui-grid-a">

                    <div class="ui-block-a">
                     <input type="password" name="passw" id="pswd" placeholder="Password" style="height:43px;">
                    </div>

                    <div class="ui-block-b">
                     <input type="button" id="sendButton" value="start" onclick="sendMessage()" />
                    </div>
                </div>
            </div>
            <div id= content2>
                <table id="mytab">
                  <thead>
                      <tr><th>id</th><th>value</th><th>unit</th></tr>
                  </thead>
<tbody id="body">
<tr id="Zeile1"><td id="Z10"></td><td id="Z11"></td><td id="Z12"></td></tr>
<tr id="Zeile2"><td id="Z20"></td><td id="Z21"></td><td id="Z22"></td></tr>
</tbody>
</table>
</div>
<div id="serverStatus"> </div> </div>
</div>
</body>
</html>
Jul 19, 2015 at 2:32 AM
Dude, You have posted your question at wrong place.
This place is for discussion of service of CodePlex.
Codeplex is an Open source project hosting site.
I believe you are asking something related to specific project which is hosted in CodePlex.
You won't find any answer here.
Try look for your project at [Search] at top right side of this page.