[Spice-devel] [PATCH 3/3] Updated example files with SPICE port event listeners

Oliver Gutierrez ogutierrez at redhat.com
Tue Sep 20 14:30:12 UTC 2016


---
 spice.html      | 10 ++++++++++
 spice_auto.html | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/spice.html b/spice.html
index c473678..f9a91c0 100644
--- a/spice.html
+++ b/spice.html
@@ -42,6 +42,7 @@
         <script src="wire.js"></script>
         <script src="spiceconn.js"></script>
         <script src="display.js"></script>
+        <script src="port.js"></script>
         <script src="main.js"></script>
         <script src="inputs.js"></script>
         <script src="webm.js"></script>
@@ -142,6 +143,15 @@
                 }
             }
 
+            window.addEventListener('spice-port-data', function(event) {
+                var msg_text = new TextDecoder('utf-8').decode(new Uint8Array(event.detail.data));
+                console.log('SPICE port', event.detail.channel.portName, 'message text:', msg_text);
+            });
+
+            window.addEventListener('spice-port-event', function(event) {
+                console.log('SPICE port', event.detail.channel.portName, 'event data:', event.detail.spiceEvent);
+            });
+
         </script>
 
     </head>
diff --git a/spice_auto.html b/spice_auto.html
index 1179ebe..48a6bda 100644
--- a/spice_auto.html
+++ b/spice_auto.html
@@ -42,6 +42,7 @@
         <script src="wire.js"></script>
         <script src="spiceconn.js"></script>
         <script src="display.js"></script>
+        <script src="port.js"></script>
         <script src="main.js"></script>
         <script src="inputs.js"></script>
         <script src="webm.js"></script>
@@ -182,6 +183,15 @@
                 }
             }
 
+            window.addEventListener('spice-port-data', function(event) {
+                var msg_text = new TextDecoder('utf-8').decode(new Uint8Array(event.detail.data));
+                console.log('SPICE port', event.detail.channel.portName, 'message text:', msg_text);
+            });
+
+            window.addEventListener('spice-port-event', function(event) {
+                console.log('SPICE port', event.detail.channel.portName, 'event data:', event.detail.spiceEvent);
+            });
+
             connect();
         </script>
 
-- 
2.7.4



More information about the Spice-devel mailing list