tlsd 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tlsd",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "A server for web app prototyping with HTTPS and Websockets",
5
5
  "main": "tlsd.js",
6
6
  "bin": {
@@ -118,8 +118,9 @@
118
118
  var socket = new WebSocket( ( loc.protocol == "http:" ? "ws:" : "wss:" ) + "//" + loc.host + path )
119
119
 
120
120
  socket.onerror = function( evt ) {
121
- DBG( "error:", evt.data );
122
- cb_ctrl( "error", evt.data );
121
+ evt.preventDefault();
122
+ DBG( "error:", evt );
123
+ cb_ctrl( "error", evt );
123
124
  }
124
125
 
125
126
  socket.onclose = function() {
@@ -9,6 +9,8 @@
9
9
  document.write( Date() );
10
10
  </script>
11
11
 
12
+ <div id=connect_status>?</div>
13
+
12
14
  <script src="/rpc/rpc.js"></script>
13
15
 
14
16
  <script>
@@ -32,9 +34,17 @@
32
34
 
33
35
  RPC.on_connect = function( evt ) {
34
36
  // RPC is ready to be used
35
- RPC( { action: "hello" }, console.log, alert )
37
+ RPC( { action: "hello" }, msg => {
38
+ document.getElementById( "connect_status" ).innerText = msg;
39
+ } );
36
40
  }
37
41
 
42
+ RPC.on_disconnect = function( evt ) {
43
+ // The websocket connection ws lost for some reason
44
+ // The RPC code will reconnect automatically
45
+ document.getElementById( "connect_status" ).innerText = "[ DISCONNECTED ]";
46
+ }
47
+
38
48
  </script>
39
49
 
40
50
  </body>
@@ -9,3 +9,6 @@ h1
9
9
  a
10
10
  font-style: italic
11
11
 
12
+ #connect_status
13
+ margin: 2em 0
14
+ font-size: 200%
@@ -9,4 +9,9 @@ h1 {
9
9
  }
10
10
  h1 a {
11
11
  font-style: italic;
12
+ }
13
+
14
+ #connect_status {
15
+ margin: 2em 0;
16
+ font-size: 200%;
12
17
  }