github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/integration/messagebus/glue/sample/Channels/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  		// Channel
    54  		// #######
    55  		var c = socket.channel("IAC");
    56  
    57  		c.onMessage(function(data) {
    58          console.log(data);
    59      });
    60  
    61  		c.send("Hello World");
    62  
    63  
    64      var count = 0;
    65  
    66  		var b1 = document.getElementById("b1");
    67  		b1.addEventListener("click", function() {
    68          var data = (++count) + ": Hello Gophers!";
    69          c.send(data);
    70      });
    71  	</script>
    72  </body>
    73  </html>