-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
35 lines (35 loc) · 1.31 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!doctype html>
<html>
<head>
<script src="node_modules/socket.io-client/dist/socket.io.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/zone.js/dist/zone-patch-socket-io.js"></script>
<script>
Zone[Zone.__symbol__('socketio')](io);
var socket = io('http://localhost:8086');
var zone = Zone.current.fork({
name: 'socketio',
onScheduleTask: function(delegate, curr, target, task) {
console.log('schedule task', task.type, task.source);
return delegate.scheduleTask(target, task);
},
onInvokeTask: function(delegate, curr, target, task, applyThis, applyArgs, source) {
console.log('invoke task', task.type, task.source);
return delegate.invokeTask(target, task, applyThis, applyArgs, source);
},
onCancelTask: function(delegate, curr, target, task) {
console.log('cancel task', task.type, task.source);
return delegate.cancelTask(target, task);
}
});
zone.run(function() {
socket.on('news', function (data) {
console.log(data);
console.log('zone', Zone.current.name);
socket.emit('my other event', { my: 'data' });
socket.off('news');
});
});
</script>
</head>
</html>