fix handle sdp messages via http
This commit is contained in:
parent
e24b708561
commit
7224de69b7
@ -14,5 +14,5 @@ app.get('/', (req, res, next) => {
|
|||||||
res.send(publicContent);
|
res.send(publicContent);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use('/:key', authMiddleware, require('./v1/public'));
|
app.use('/:key', require('./v1/public'));
|
||||||
app.use('/:key/:id/:token', authMiddleware, jsonParser, require('./v1/calls'));
|
app.use('/:key/:id/:token', authMiddleware, jsonParser, require('./v1/calls'));
|
||||||
|
@ -10,7 +10,7 @@ module.exports = (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return next();
|
return res.sendStatus(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = realm.getClientById(id);
|
const client = realm.getClientById(id);
|
||||||
|
@ -1,42 +1,34 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
// const realm = require('../../../realm');
|
const realm = require('../../../services/realm');
|
||||||
|
const messageHandler = require('../../../messageHandler');
|
||||||
|
|
||||||
const app = module.exports = express.Router();
|
const app = module.exports = express.Router();
|
||||||
|
|
||||||
// const handle = (req, res, next) => {
|
const handle = (req, res, next) => {
|
||||||
// var id = req.params.id;
|
const { id } = req.params;
|
||||||
|
|
||||||
// let client;
|
if (!id) return next();
|
||||||
// if (!(client = realm.getClientById(id))) {
|
|
||||||
// if (req.params.retry) {
|
|
||||||
// res.sendStatus(401);
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// // Retry this request
|
|
||||||
// req.params.retry = true;
|
|
||||||
// setTimeout(handle, 25, req, res);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Auth the req
|
const client = realm.getClientById(id);
|
||||||
// if (client.token && req.params.token !== client.token) {
|
|
||||||
// res.sendStatus(401);
|
|
||||||
// } else {
|
|
||||||
// self._handleTransmission(key, {
|
|
||||||
// type: req.body.type,
|
|
||||||
// src: id,
|
|
||||||
// dst: req.body.dst,
|
|
||||||
// payload: req.body.payload
|
|
||||||
// });
|
|
||||||
// res.sendStatus(200);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// app.post('/:key/:id/:token/offer', jsonParser, handle);
|
const { type, dst, payload } = req.body;
|
||||||
|
|
||||||
// app.post('/:key/:id/:token/candidate', jsonParser, handle);
|
const message = {
|
||||||
|
type,
|
||||||
|
src: id,
|
||||||
|
dst,
|
||||||
|
payload
|
||||||
|
};
|
||||||
|
|
||||||
// app.post('/:key/:id/:token/answer', jsonParser, handle);
|
messageHandler(client, message);
|
||||||
|
|
||||||
// app.post('/:key/:id/:token/leave', jsonParser, handle);
|
res.sendStatus(200);
|
||||||
|
};
|
||||||
|
|
||||||
|
app.post('/offer', handle);
|
||||||
|
|
||||||
|
app.post('/candidate', handle);
|
||||||
|
|
||||||
|
app.post('/answer', handle);
|
||||||
|
|
||||||
|
app.post('/leave', handle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user