3d-interface/posts/keyboard-event/index.js

35 lines
903 B
JavaScript
Raw Normal View History

2015-05-19 14:25:35 +02:00
var pg = require('pg');
var secret = require('../../private');
module.exports.index = function(req, res) {
var user_id = req.session.user_id;
var camera = req.body.camera;
pg.connect(secret.url, function(err, client, release) {
client.query(
"INSERT INTO keyboardevent(user_id, direction, camera, time)" +
"VALUES($1, NULL, ROW(ROW($2,$3,$4),ROW($5,$6,$7)), to_timestamp($8));" ,
2015-05-19 14:25:35 +02:00
[
user_id,
camera.position.x,
camera.position.y,
camera.position.z,
camera.target.x,
camera.target.y,
camera.target.z,
req.body.time
2015-05-19 14:25:35 +02:00
],
function(err, result) {
release();
}
);
});
res.setHeader('Content-Type', 'text/html');
res.send("user_id = " + user_id);
}