diff options
| author | ivanshen <iwshen11@gmail.com> | 2019-03-05 21:39:35 +0000 |
|---|---|---|
| committer | ivanshen <iwshen11@gmail.com> | 2019-03-05 21:39:35 +0000 |
| commit | 3b36b1ad459ee739a87a32a18bb5846770125bec (patch) | |
| tree | 259c5173be1992fdcf053d80fdcccb200c4bc903 /web/routes | |
| parent | 9f5447a54ba8bbbcc271035d180822efedce6670 (diff) | |
modularize plot points
Diffstat (limited to 'web/routes')
| -rw-r--r-- | web/routes/index.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/web/routes/index.js b/web/routes/index.js index 885724d..b2ba91f 100644 --- a/web/routes/index.js +++ b/web/routes/index.js @@ -36,6 +36,7 @@ router.post('/mobilerequest', function(req, res) { console.log(`err inserting mobile request into db: ${err}`); res.status(500).send({ error: "boo:(" }); } else { + // send event to all connections for(var i = 0; i < connections.length; i++) { connections[i].sseSend(data); } @@ -48,8 +49,11 @@ router.post('/mobilerequest', function(req, res) { router.get('/stream', function(req, res){ - res.sseSetup() + // set up server side event (communication line between front end and server) + res.sseSetup(); + // send an event to the front end to open the connection res.sseSend('ok'); + // push connection to connection array connections.push(res); }); module.exports = router; |
