Files
pixel-streaming-coordinator/src/controllers/session_server.js
T

45 lines
1.0 KiB
JavaScript

const server_error = require('../../lib/src/http/errors/server_error')
const database = require('../database/database')
const session_closed = async (req, res, next) => {
const {
session_id,
title,
max_uniq_users,
users_at_close,
time,
unix_timestamp,
time_end,
unix_timestamp_end
} = req.body
let active_session = await database.get_active_session(session_id)
if (active_session) {
await database.add_session_to_history(
session_id,
title,
active_session.server_url,
active_session.websocket_url,
max_uniq_users,
users_at_close,
time,
unix_timestamp,
time_end,
unix_timestamp_end
)
}
let remove_result = await database.remove_active_session(session_id)
if (!remove_result) {
next(new server_error('remove session error'))
return
}
res.json({message:"successfully removed"})
}
module.exports = {
session_closed
}