github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/integration/messagebus/glue/sample/OnlyWrite/public/index.html (about)

     1  <!DOCTYPE html>
     2  <html>
     3  <head>
     4  	<meta charset="utf8" />
     5  	<title>Glue Socket Test</title>
     6    <script src="/dist/glue.js"></script>
     7  </head>
     8  <body>
     9  	<h1>Glue Socket Test</h1>
    10  
    11      <button id="b1">Button</button>
    12  
    13  	<script>
    14  		var socket = glue();
    15  
    16          socket.onMessage(function(data) {
    17              console.log("onMessage: " + data);
    18          });
    19  
    20          socket.on("connected", function() {
    21              console.log("connected");
    22              socket.send("Hello Server");
    23          });
    24  
    25          socket.on("connecting", function() {
    26              console.log("connecting");
    27          });
    28  
    29          socket.on("disconnected", function() {
    30              console.log("disconnected");
    31          });
    32  
    33          socket.on("reconnecting", function() {
    34              console.log("reconnecting");
    35          });
    36  
    37          socket.on("error", function(e, msg) {
    38              console.log("error: " + msg);
    39          });
    40  
    41          socket.on("connect_timeout", function() {
    42              console.log("connect_timeout");
    43          });
    44  
    45          socket.on("timeout", function() {
    46              console.log("timeout");
    47          });
    48  
    49          socket.on("discard_send_buffer", function() {
    50  			console.log("some data could not be send and was discarded.");
    51          });
    52  
    53  
    54          //################//
    55  
    56          var count = 0;
    57  
    58  				var b1 = document.getElementById("b1");
    59  				b1.addEventListener("click", function() {
    60              var data = (++count) + ": Hello World!";
    61              console.log("client send message: " + data);
    62              socket.send(data);
    63          });
    64  	</script>
    65  </body>
    66  </html>