Skip to content

Commit

Permalink
Added priority lock
Browse files Browse the repository at this point in the history
  • Loading branch information
osztenkurden committed Jul 29, 2020
1 parent e556ce8 commit 964eb53
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dist/server/sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,23 @@ function default_1(server, app) {
radar.startRadar(app, io);
app.post('/', function (req, res) {
runtimeConfig.last = req.body;
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
io.emit('enableTest', true);
}
io.emit('update', req.body);
exports.GSI.digest(req.body);
radar.digestRadar(req.body);
res.sendStatus(200);
});
app.post('/api/test', function (_req, res) {
var _a, _b;
res.sendStatus(200);
if (intervalId)
return;
if (((_b = (_a = runtimeConfig.last) === null || _a === void 0 ? void 0 : _a.provider) === null || _b === void 0 ? void 0 : _b.timestamp) && (new Date()).getTime() - runtimeConfig.last.provider.timestamp * 1000 <= 5000)
return;
io.emit('enableTest', false);
var i = 0;
intervalId = setInterval(function () {
Expand Down
11 changes: 11 additions & 0 deletions server/sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ export default function (server: http.Server, app: express.Router) {

app.post('/', (req, res) => {
runtimeConfig.last = req.body;

if(intervalId){
clearInterval(intervalId);
intervalId = null;
io.emit('enableTest', true);
}

io.emit('update', req.body);
GSI.digest(req.body);
radar.digestRadar(req.body);
Expand All @@ -249,8 +256,12 @@ export default function (server: http.Server, app: express.Router) {

app.post('/api/test', (_req, res) => {
res.sendStatus(200);

if(intervalId) return;
if(runtimeConfig.last?.provider?.timestamp && (new Date()).getTime() - runtimeConfig.last.provider.timestamp*1000 <= 5000) return;

io.emit('enableTest', false);

let i = 0;
intervalId = setInterval(() => {
if(!testData[i]) {
Expand Down

0 comments on commit 964eb53

Please sign in to comment.