2018-08-30 14:22:57 +00:00
|
|
|
require("dotenv").config();
|
|
|
|
const WebSocket = require("ws");
|
|
|
|
const WebSocketStream = require("websocket-stream");
|
|
|
|
const http = require('http');
|
2018-08-29 17:20:48 +00:00
|
|
|
|
|
|
|
|
2018-08-30 14:22:57 +00:00
|
|
|
/**
|
|
|
|
* HTTP Server with Websocket which is responsible for:
|
|
|
|
* - Recieving User Audio Media
|
|
|
|
* - Recieving Data relating to which users are in what channel
|
|
|
|
*/
|
2018-08-30 10:49:09 +00:00
|
|
|
class WebSocketServer {
|
|
|
|
constructor() {
|
2018-08-30 14:22:57 +00:00
|
|
|
const server = http.createServer();
|
|
|
|
this.stream = WebSocketStream.createServer({ server: server },this.handleStream);
|
2018-08-29 17:20:48 +00:00
|
|
|
|
2018-08-30 14:22:57 +00:00
|
|
|
server.listen(process.env.PORT || 1337)
|
2018-08-29 17:20:48 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 10:49:09 +00:00
|
|
|
handleStream(stream, req) {
|
2018-08-30 14:22:57 +00:00
|
|
|
console.log(stream);
|
2018-08-29 17:20:48 +00:00
|
|
|
}
|
2018-08-30 14:22:57 +00:00
|
|
|
|
|
|
|
checkIfBuffer(stream) {
|
|
|
|
|
2018-08-29 17:20:48 +00:00
|
|
|
}
|
2018-08-29 12:24:38 +00:00
|
|
|
}
|
2018-08-29 17:20:48 +00:00
|
|
|
|
2018-08-30 10:49:09 +00:00
|
|
|
const wss = new WebSocketServer();
|