Skip to content

Commit 396420d

Browse files
wchilltehp
authored andcommitted
Use WebSockets for terminal output (#69)
1 parent b5bb1f1 commit 396420d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
</div>
9595

9696
<div id="map"></div>
97+
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
9798
<script type="text/javascript" src="config/userdata.js"></script>
9899
<script type="text/javascript" src="js/main.js"></script>
99100
</body>

js/main.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
$(document).ready(function() {
44
mapView.init();
5+
var socket = io.connect('http://' + document.domain + ':' + location.port + '/event');
6+
socket.on('connect', function() {
7+
console.log('connected!');
8+
});
9+
socket.on('logging', function(msg) {
10+
for(var i = 0; i < msg.length; i++) {
11+
mapView.log({
12+
message: msg[i].output,
13+
color: msg[i].color + "-text"
14+
});
15+
}
16+
});
517
});
618

719
var mapView = {
@@ -819,4 +831,4 @@ if (!String.prototype.format) {
819831
return typeof args[number] != 'undefined' ? args[number] : match;
820832
});
821833
};
822-
}
834+
}

0 commit comments

Comments
 (0)