Skip to content

Commit 7ca62e8

Browse files
Bannister, Keith (CASS, Marsfield)Bannister, Keith (CASS, Marsfield)
Bannister, Keith (CASS, Marsfield)
authored and
Bannister, Keith (CASS, Marsfield)
committed
Add stuff we moved from elsewhere
1 parent 073b5d1 commit 7ca62e8

39 files changed

+2287
-0
lines changed

app.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
var createError = require('http-errors');
2+
var express = require('express');
3+
var path = require('path');
4+
var cookieParser = require('cookie-parser');
5+
var logger = require('morgan');
6+
//var session = require('express-session');
7+
8+
var indexRouter = require('./routes/index');
9+
var usersRouter = require('./routes/users');
10+
11+
var app = express();
12+
13+
// view engine setup
14+
app.set('views', path.join(__dirname, 'views'));
15+
app.set('view engine', 'jade');
16+
17+
app.use(logger('dev'));
18+
app.use(express.json());
19+
app.use(express.urlencoded({ extended: false }));
20+
app.use(cookieParser());
21+
app.use(express.static(path.join(__dirname, 'public')));
22+
23+
app.use('/', indexRouter);
24+
app.use('/users', usersRouter);
25+
26+
// Add sessoin
27+
var sess = {
28+
secret: '@!Ew8Bjkg1',
29+
cookie: {}
30+
}
31+
32+
if (app.get('env') === 'production') {
33+
app.set('trust proxy', 1) // trust first proxy
34+
sess.cookie.secure = true // serve secure cookies
35+
}
36+
37+
//app.use(session(sess))
38+
39+
40+
// catch 404 and forward to error handler
41+
app.use(function(req, res, next) {
42+
next(createError(404));
43+
});
44+
45+
// error handler
46+
app.use(function(err, req, res, next) {
47+
// set locals, only providing error in development
48+
res.locals.message = err.message;
49+
res.locals.error = req.app.get('env') === 'development' ? err : {};
50+
51+
// render the error page
52+
res.status(err.status || 500);
53+
res.render('error');
54+
});
55+
56+
module.exports = app;

bin/www

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
var app = require('../app');
8+
var debug = require('debug')('hedzapp:server');
9+
var http = require('http');
10+
11+
/**
12+
* Get port from environment and store in Express.
13+
*/
14+
15+
var port = normalizePort(process.env.PORT || '3000');
16+
app.set('port', port);
17+
18+
/**
19+
* Create HTTP server.
20+
*/
21+
22+
var server = http.createServer(app);
23+
24+
/**
25+
* Listen on provided port, on all network interfaces.
26+
*/
27+
28+
server.listen(port);
29+
server.on('error', onError);
30+
server.on('listening', onListening);
31+
32+
/**
33+
* Setup socketio and put in express app so routes can use it.
34+
* Trick see: https://stackoverflow.com/questions/18856190/use-socket-io-inside-a-express-routes-file
35+
*/
36+
const io = require('socket.io').listen(server);
37+
app.set('socketio', io);
38+
39+
/**
40+
* Normalize a port into a number, string, or false.
41+
*/
42+
43+
function normalizePort(val) {
44+
var port = parseInt(val, 10);
45+
46+
if (isNaN(port)) {
47+
// named pipe
48+
return val;
49+
}
50+
51+
if (port >= 0) {
52+
// port number
53+
return port;
54+
}
55+
56+
return false;
57+
}
58+
59+
/**
60+
* Event listener for HTTP server "error" event.
61+
*/
62+
63+
function onError(error) {
64+
if (error.syscall !== 'listen') {
65+
throw error;
66+
}
67+
68+
var bind = typeof port === 'string'
69+
? 'Pipe ' + port
70+
: 'Port ' + port;
71+
72+
// handle specific listen errors with friendly messages
73+
switch (error.code) {
74+
case 'EACCES':
75+
console.error(bind + ' requires elevated privileges');
76+
process.exit(1);
77+
break;
78+
case 'EADDRINUSE':
79+
console.error(bind + ' is already in use');
80+
process.exit(1);
81+
break;
82+
default:
83+
throw error;
84+
}
85+
}
86+
87+
/**
88+
* Event listener for HTTP server "listening" event.
89+
*/
90+
91+
function onListening() {
92+
var addr = server.address();
93+
var bind = typeof addr === 'string'
94+
? 'pipe ' + addr
95+
: 'port ' + addr.port;
96+
debug('Listening on ' + bind);
97+
}

ecosystem.config.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
apps: [{
3+
name: 'rockethedz',
4+
script: 'bin/www',
5+
watch: true,
6+
env: {
7+
"NODE_ENV": "development",
8+
},
9+
env_production: {
10+
"NODE_ENV": "production"
11+
}
12+
}],
13+
14+
deploy: {
15+
production: {
16+
user: 'keith',
17+
host: 'hedz',
18+
ref: 'origin/master',
19+
repo: '[email protected]:strocode/hedz.git',
20+
path: '/home/keith/RocketHedz/',
21+
'pre-deploy-local': '',
22+
'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --env production',
23+
'pre-setup': ''
24+
}
25+
}
26+
};

package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "hedzapp",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"start": "node ./bin/www",
7+
"build": "webpack"
8+
},
9+
"dependencies": {
10+
"canvas": "^2.6.1",
11+
"cookie-parser": "~1.4.4",
12+
"datauri": "^3.0.0",
13+
"debug": "~2.6.9",
14+
"express": "~4.16.1",
15+
"express-session": "^1.17.1",
16+
"http-errors": "~1.6.3",
17+
"jade": "~1.11.0",
18+
"jsdom": "^16.2.2",
19+
"morgan": "~1.9.1",
20+
"nodemailer": "^6.4.8",
21+
"save-dev": "0.0.1-security",
22+
"socket.io": "^2.3.0"
23+
},
24+
"devDependencies": {
25+
"@babel/core": "^7.9.6",
26+
"@babel/preset-env": "^7.9.6",
27+
"babel-loader": "^8.1.0",
28+
"webpack": "^4.43.0",
29+
"webpack-cli": "^3.3.11"
30+
}
31+
}

public/game/assets/enemyBlack5.png

2.08 KB
Loading

public/game/assets/spaceShips_001.png

3.79 KB
Loading

public/game/assets/star_gold.png

512 Bytes
Loading

public/game/debug_index.html

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
</head>
7+
8+
<body>
9+
10+
<div id="videos"></div>
11+
12+
13+
<div id="game-div"></div>
14+
15+
<button id="webcam-button">Send webcam</button>
16+
<button id="screen-button">Send screen</button>
17+
<button id="cutout-button">Send cutout</button>
18+
<button id="audio-button">Send audio</button>
19+
20+
21+
<h2>Options</h2>
22+
<div class="option">
23+
<input id="use-datachannel" checked="checked" type="checkbox"/>
24+
<label for="use-datachannel">Use datachannel</label>
25+
<select id="datachannel-parameters">
26+
<option value='{"ordered": true}'>Ordered, reliable</option>
27+
<option value='{"ordered": false, "maxRetransmits": 0}'>Unordered, no retransmissions</option>
28+
<option value='{"ordered": false, "maxPacketLifetime": 500}'>Unordered, 500ms lifetime</option>
29+
</select>
30+
</div>
31+
<div class="option">
32+
<input id="use-audio" checked="checked" type="checkbox"/>
33+
<label for="use-audio">Use audio</label>
34+
<select id="audio-codec">
35+
<option value="default" selected>Default codecs</option>
36+
<option value="opus/48000/2">Opus</option>
37+
<option value="PCMU/8000">PCMU</option>
38+
<option value="PCMA/8000">PCMA</option>
39+
</select>
40+
</div>
41+
<div class="option">
42+
<input id="use-video" type="checkbox" checked="checked"/>
43+
<label for="use-video">Use video</label>
44+
<select id="video-resolution">
45+
<option value="" >Default resolution</option>
46+
<option value="40x30" selected>40x30</option>x
47+
<option value="80x60">80x60</option>
48+
<option value="160x120">160x120</option>
49+
<option value="320x240">320x240</option>
50+
<option value="640x480">640x480</option>
51+
<option value="960x540">960x540</option>
52+
<option value="1280x720">1280x720</option>
53+
</select>
54+
<select id="video-transform">
55+
<option value="none" >No transform</option>
56+
<option value="edges">Edge detection</option>
57+
<option value="cartoon">Cartoon effect</option>
58+
<option value="rotate">Rotate</option>
59+
<option value="track" selected >Track</option>
60+
</select>
61+
<select id="video-codec">
62+
<option value="default" selected>Default codecs</option>
63+
<option value="VP8/90000">VP8</option>
64+
<option value="H264/90000">H264</option>
65+
</select>
66+
</div>
67+
<div class="option">
68+
<input id="use-stun" type="checkbox" checked="checked"/>
69+
<label for="use-stun">Use STUN server</label>
70+
</div>
71+
72+
<button id="start" onclick="start()">Start</button>
73+
<button id="stop" style="display: none" onclick="stop()">Stop</button>
74+
75+
<h2>State</h2>
76+
<p>
77+
ICE gathering state: <span id="ice-gathering-state"></span>
78+
</p>
79+
<p>
80+
ICE connection state: <span id="ice-connection-state"></span>
81+
</p>
82+
<p>
83+
Signaling state: <span id="signaling-state"></span>
84+
</p>
85+
86+
<div id="media" style="display: none">
87+
<h2>Media</h2>
88+
89+
<audio id="audio" autoplay="true"></audio>
90+
<video id="video" autoplay="true" playsinline="true"></video>
91+
</div>
92+
93+
94+
<h2>SDP</h2>
95+
96+
<h3>Offer</h3>
97+
<pre id="offer-sdp"></pre>
98+
99+
<h3>Answer</h3>
100+
<pre id="answer-sdp"></pre>
101+
102+
<h2>Data channel</h2>
103+
<pre id="data-channel" ></pre>
104+
105+
106+
<script src="/socket.io/socket.io.js"></script>
107+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script>
108+
<script src="node_modules/face-api.js/dist/face-api.min.js"></script>
109+
<script src="js/hedz.js"></script>
110+
<script src="js/game.js"></script>
111+
112+
113+
114+
115+
116+
</body>
117+
118+
119+
120+
121+
</html>

public/game/index.html

Whitespace-only changes.

0 commit comments

Comments
 (0)