forked from mstratford/CasparCG-Graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·159 lines (122 loc) · 3.71 KB
/
server.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
var express = require('express'),
http = require('http'),
Stopwatch = require('./models/stopwatch');
var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
var theme = {selected: "ury"};
var bug = {livetext: "Live", locationtext: ''};
var holdingCard = {video: "holdingcard.mp4", autoplay:true, loop: true, showAll: true, play: true, volume: false};
var timelord = { lockNowDescription: "Automatic", lockNowDescriptionCustom: "", caption: "Join the conversation! ury.org.uk • @ury1350 • 07851 101 313", nowPlayingPrefix: "Now Playing: ", lockNowTime: "", showNowNext: true, showCredits:true, showDesc:false, showNowPlaying:true, showNews: false, showNewsNow: false};
var socialmedia = {tweet: "", pos: "bottom center", tweethtml: ""};
var grid = {headingcolor:"#BC204B", leftcolor: "#1f1a34", rightcolor:"#1f1a34"};
//Clock Functions
var stopwatch = new Stopwatch();
stopwatch.on('tick:stopwatch', function(time) {
io.sockets.emit("clock:tick", time);
});
io.on('connection', function(socket) {
console.log("Client Socket Connected");
/*
* Clock functions
*/
socket.on("clock:pause", function() {
stopwatch.pause();
});
socket.on("clock:reset", function() {
stopwatch.reset();
});
socket.on("clock:up", function() {
stopwatch.countUp();
});
socket.on("clock:down", function() {
stopwatch.countDown();
});
socket.on("clock:set", function(msg) {
stopwatch.setValue(msg);
});
socket.on("clock:get", function() {
io.sockets.emit("clock:tick", stopwatch.getTime());
});
socket.on("grid", function(payload) {
grid = payload;
io.sockets.emit("grid", payload);
console.log("Updating: grid");
});
/*
* General Functions
*/
socket.on("theme", function(msg) {
theme = msg;
io.sockets.emit("theme", msg);
});
socket.on("theme:get", function(msg) {
io.sockets.emit("theme", theme);
});
socket.on("bug", function(msg) {
bug = msg;
io.sockets.emit("bug", msg);
});
socket.on("bug:get", function(msg) {
io.sockets.emit("bug", bug);
});
/*
* Holding Card
*/
socket.on("holdingCard", function(msg) {
holdingCard = msg;
io.sockets.emit("holdingCard", msg);
});
socket.on("holdingCard:get", function(msg) {
io.sockets.emit("holdingCard", holdingCard);
});
/*
* Timelord
*/
socket.on("timelord", function(msg) {
timelord = msg;
io.sockets.emit("timelord", msg);
});
socket.on("timelord:get", function(msg) {
io.sockets.emit("timelord", timelord);
});
/*
* Lower Thirds
*/
socket.on("lowerthird:left", function(msg) {
io.sockets.emit("lowerthird:left", msg);
});
socket.on("lowerthird:right", function(msg) {
io.sockets.emit("lowerthird:right", msg);
});
socket.on("lowerthird:full", function(msg) {
io.sockets.emit("lowerthird:full", msg);
});
socket.on("lowerthird:hidefull", function() {
io.sockets.emit("lowerthird:hidefull");
});
socket.on("lowerthird:hideleft", function() {
io.sockets.emit("lowerthird:hideleft");
});
socket.on("lowerthird:hideright", function() {
io.sockets.emit("lowerthird:hideright");
});
socket.on("lowerthird:hideall", function() {
io.sockets.emit("lowerthird:hideall");
});
/*
* Social Media
*/
socket.on("socialmedia", function(msg) {
socialmedia = msg;
io.sockets.emit("socialmedia", msg);
});
socket.on("socialmedia:get", function(msg) {
io.sockets.emit("socialmedia", socialmedia);
});
});
//Serve the puplic dir
app.use(express.static(__dirname + "/public"));
server.listen(3000);
console.log("Now listening on port 3000. Go to http://127.0.0.1:3000/admin to control")
console.log("run 'play 1-1 [html] http://127.0.0.1:3000' in CasparCG to start the graphics")