Skip to content
Browse files

Echo out all messages on socket (*trying* to add support for FF) and …

…updated demo support list
  • Loading branch information...
1 parent ac56470 commit 1841e4ac6401ba77a5583072500b9c15fe7016cf @remy remy committed
Showing with 9 additions and 3 deletions.
  1. +1 −1 demos.json
  2. +8 −2 demos/web-socket.html
View
2 demos.json
@@ -23,7 +23,7 @@
"url": "dataset",
"tags": "dataset",
"support": {
- "live": "chrome opera safari",
+ "live": "chrome opera safari firefox",
"nightly": ""
},
"test": "'dataset' in document.createElement('i')"
View
10 demos/web-socket.html
@@ -29,6 +29,11 @@
<ul id="log"></ul>
</article>
<script>
+// let's invite Firefox to the party.
+if (window.MozWebSocket) {
+ window.WebSocket = window.MozWebSocket;
+}
+
function openConnection() {
// uses global 'conn' object
if (conn.readyState === undefined || conn.readyState > 1) {
@@ -39,8 +44,9 @@
};
conn.onmessage = function (event) {
- var message = JSON.parse(event.data);
- if (typeof message == 'string') {
+ // console.log(event.data);
+ var message = event.data; //JSON.parse(event.data);
+ if (!(/^\d+$/).test(message)) {
log.innerHTML = '<li class="them">' + message.replace(/[<>&]/g, function (m) { return entities[m]; }) + '</li>' + log.innerHTML;
} else {
connected.innerHTML = message;

0 comments on commit 1841e4a

Please sign in to comment.
Something went wrong with that request. Please try again.