123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- const path = require('path');
- const express = require('express');
- const WebSocket = require('ws');
- const app = express();
- const path1 = require('path');
- const express1 = require('express');
- const WebSocket1 = require('ws');
- const path2 = require('path');
- const express2 = require('express');
- const WebSocket2 = require('ws');
- const path3 = require('path');
- const express3 = require('express');
- const WebSocket3 = require('ws');
- const path4 = require('path');
- const express4 = require('express');
- const WebSocket4 = require('ws');
- const path5 = require('path');
- const express5 = require('express');
- const WebSocket5 = require('ws');
- const WS_PORT = 8088;
- const HTTP_PORT = 8000;
- const WS_PORT1 = 8089;
- const WS_PORT2 = 8090;
- const WS_PORT3 = 8091;
- const WS_PORT4 = 8092;
- const WS_PORT5 = 8093;
- const wsServer = new WebSocket.Server({port: WS_PORT}, ()=> console.log(`WS Server is listening at ${WS_PORT}`));
- let connectedClients = [];
- wsServer.on('connection', (ws, req)=>{
- console.log('Connected');
- connectedClients.push(ws);
- ws.on('message', data => {
- connectedClients.forEach((ws,i)=>{
- if(ws.readyState === ws.OPEN){
- ws.send(data);
- }else{
- connectedClients.splice(i ,1);
- }
- })
- });
- });
- const wsServer1 = new WebSocket.Server({port: WS_PORT1}, ()=> console.log(`WS Server is listening at ${WS_PORT1}`));
- let connectedClients1 = [];
- wsServer1.on('connection', (ws1, req)=>{
- console.log('Connected');
- connectedClients1.push(ws1);
- ws1.on('message', data1 => {
- connectedClients1.forEach((ws1,i)=>{
- if(ws1.readyState === ws1.OPEN){
- ws1.send(data1);
- }else{
- connectedClients1.splice(i ,1);
- }
- })
- });
- });
- const wsServer2 = new WebSocket.Server({port: WS_PORT2}, ()=> console.log(`WS Server is listening at ${WS_PORT2}`));
- let connectedClients2 = [];
- wsServer2.on('connection', (ws2, req)=>{
- console.log('Connected');
- connectedClients2.push(ws2);
- ws2.on('message', data2 => {
- connectedClients2.forEach((ws2,i)=>{
- if(ws2.readyState === ws2.OPEN){
- ws2.send(data2);
- }else{
- connectedClients2.splice(i ,1);
- }
- })
- });
- });
- const wsServer3 = new WebSocket.Server({port: WS_PORT3}, ()=> console.log(`WS Server is listening at ${WS_PORT3}`));
- let connectedClients3 = [];
- wsServer3.on('connection', (ws3, req)=>{
- console.log('Connected');
- connectedClients3.push(ws3);
- ws3.on('message', data3 => {
- connectedClients3.forEach((ws3,i)=>{
- if(ws3.readyState === ws3.OPEN){
- ws3.send(data3);
- }else{
- connectedClients3.splice(i ,1);
- }
- })
- });
- });
- const wsServer4 = new WebSocket.Server({port: WS_PORT4}, ()=> console.log(`WS Server is listening at ${WS_PORT4}`));
- let connectedClients4 = [];
- wsServer4.on('connection', (ws4, req)=>{
- console.log('Connected');
- connectedClients4.push(ws4);
- ws4.on('message', data4 => {
- connectedClients4.forEach((ws4,i)=>{
- if(ws4.readyState === ws4.OPEN){
- ws4.send(data4);
- }else{
- connectedClients4.splice(i ,1);
- }
- })
- });
- });
- const wsServer5 = new WebSocket.Server({port: WS_PORT5}, ()=> console.log(`WS Server is listening at ${WS_PORT5}`));
- let connectedClients5 = [];
- wsServer5.on('connection', (ws5, req)=>{
- console.log('Connected');
- connectedClients5.push(ws5);
- ws5.on('message', data5 => {
- connectedClients5.forEach((ws5,i)=>{
- if(ws5.readyState === ws5.OPEN){
- ws5.send(data5);
- }else{
- connectedClients5.splice(i ,1);
- }
- })
- });
- });
- //app.get('/client',(req,res)=>res.sendFile(path.resolve(__dirname, '/home/gs1801/CoffeeProject/app/templates/video.html')));
- app.get('/client',(req,res)=>res.sendFile(path.resolve(__dirname, '/home/gs1801/Rita/Coffee/templates/dry_containter.html')));
- app.listen(HTTP_PORT, ()=> console.log(`HTTP server listening at ${HTTP_PORT}`));
|