forked from dannybrian/nfjs-fullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client-network.js
115 lines (96 loc) · 3.3 KB
/
client-network.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Copyright (c) 2014 Danny Brian <[email protected]>
*
*/
var io = io('http://g4tp.com/danny', { path: '/node/socket.io'} );
//var io = io('http://192.168.1.50/danny', { path: '/node/socket.io'} );
(function(window, undefined) {
var connected = document.createEvent("Event");
connected.initEvent("connected",true,true);
io.on('connect', function(event){
connected.event = event;
document.dispatchEvent(connected);
});
var disconnect = document.createEvent("Event");
disconnect.initEvent("disconnected",true,true);
io.on('connect_error', function(error){
disconnect.error = error;
document.dispatchEvent(disconnect);
});
var stats = document.createEvent("Event");
stats.initEvent("stats",true,true);
io.on('stats', function(data) {
stats.stats = data;
document.dispatchEvent(stats);
});
var votes = document.createEvent("Event");
votes.initEvent("votes",true,true);
io.on('votes', function(data) {
votes.votes = data;
document.dispatchEvent(votes);
});
var vote = document.createEvent("Event");
vote.initEvent("vote",true,true);
io.on('vote', function(data) {
vote.vote = data;
// console.log(data);
document.dispatchEvent(vote);
});
var answer = document.createEvent("Event");
answer.initEvent("answer",true,true);
io.on('answer', function(data) {
answer.answer = data;
// console.log(answer);
document.dispatchEvent(answer);
});
var answers = document.createEvent("Event");
answers.initEvent("answers",true,true);
io.on('answers', function(data) {
answers.answers = data;
// console.log(answer);
document.dispatchEvent(answers);
});
var authenticated = document.createEvent("Event");
authenticated.initEvent("authenticated",true,true);
io.on('authenticated', function(data) {
authenticated.data = data;
document.dispatchEvent(authenticated);
});
var badauth = document.createEvent("Event");
badauth.initEvent("badauth",true,true);
io.on('badauth', function(data) {
badauth.data = data;
document.dispatchEvent(badauth);
});
var follow = document.createEvent("Event");
follow.initEvent("follow",true,true);
io.on('follow', function(data) {
follow.follow = data;
document.dispatchEvent(follow);
});
var admin = document.createEvent("Event");
admin.initEvent("admin-msg",true,true);
io.on('admin-msg', function(data) {
admin.admin = data;
document.dispatchEvent(admin);
});
})(this);
// for global namespace calls from unity
function nextSubEvent () {
var trigger = document.createEvent("Event");
trigger.initEvent("trigger",true,true);
trigger.trigger = { type: "nextSubEvent" };
document.dispatchEvent(trigger);
}
function fadeWhite () {
var trigger = document.createEvent("Event");
trigger.initEvent("trigger",true,true);
trigger.trigger = { type: "fadeWhite" };
document.dispatchEvent(trigger);
}
function pathPaused () {
var trigger = document.createEvent("Event");
trigger.initEvent("trigger",true,true);
trigger.trigger = { type: "pathPaused" };
document.dispatchEvent(trigger);
}