Add checking to make sure received message is valid
This commit is contained in:
parent
fd95bd10b7
commit
71598b8d76
14
server.js
14
server.js
|
@ -17,14 +17,18 @@ app.get('/*', (req, res) => {
|
|||
|
||||
app.post('*', (req, res) => {
|
||||
let id = req.path.substring(1);
|
||||
let message = Object.keys(req.body)[0];
|
||||
let data = Object.keys(req.body)[0];
|
||||
|
||||
console.log("to: " + id);
|
||||
console.log(message);
|
||||
if (data && data.substring(0,2) === 'd:') {
|
||||
let message = data.substring(2);
|
||||
|
||||
io.in(id).emit('message', message);
|
||||
console.log("to: " + id);
|
||||
console.log(message);
|
||||
|
||||
res.end();
|
||||
io.in(id).emit('message', message);
|
||||
|
||||
res.end();
|
||||
}
|
||||
});
|
||||
|
||||
const server = app.listen(port, 'localhost', (err) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user