Browse Source

Fix

hosting-provider
Evan Feenstra 5 years ago
parent
commit
b6270756d0
  1. 11
      api/utils/socket.ts
  2. 10
      dist/api/utils/socket.js
  3. 2
      dist/api/utils/socket.js.map

11
api/utils/socket.ts

@ -4,28 +4,29 @@ import * as WebSocket from 'ws'
// let connectionCounter = 0 // let connectionCounter = 0
// let lastConn: any // let lastConn: any
let server: any let srvr: any
const connect = (server) => { const connect = (server) => {
server = new WebSocket.Server({ server, clientTracking:true }) srvr = new WebSocket.Server({ server, clientTracking:true })
console.log('=> [socket] connected to server') console.log('=> [socket] connected to server')
server.on('connection', socket => { srvr.on('connection', socket => {
console.log('=> [socket] connection received') console.log('=> [socket] connection received')
// var id = connectionCounter++; // var id = connectionCounter++;
// connections.set(id, socket) // connections.set(id, socket)
// lastConn = socket // lastConn = socket
console.log(srvr)
}) })
} }
const send = (body) => { const send = (body) => {
console.log(srvr)
// connections.forEach((socket, index) => { // connections.forEach((socket, index) => {
// socket.send(body) // socket.send(body)
// }) // })
// if(lastConn) lastConn.send(body) // if(lastConn) lastConn.send(body)
server.clients.forEach(c=>{ srvr.clients.forEach(c=>{
if(c && c.connected) { if(c && c.connected) {
c.send(body) c.send(body)
} }

10
dist/api/utils/socket.js

@ -4,24 +4,26 @@ const WebSocket = require("ws");
// let connections = new Map() // let connections = new Map()
// let connectionCounter = 0 // let connectionCounter = 0
// let lastConn: any // let lastConn: any
let server; let srvr;
const connect = (server) => { const connect = (server) => {
server = new WebSocket.Server({ server, clientTracking: true }); srvr = new WebSocket.Server({ server, clientTracking: true });
console.log('=> [socket] connected to server'); console.log('=> [socket] connected to server');
server.on('connection', socket => { srvr.on('connection', socket => {
console.log('=> [socket] connection received'); console.log('=> [socket] connection received');
// var id = connectionCounter++; // var id = connectionCounter++;
// connections.set(id, socket) // connections.set(id, socket)
// lastConn = socket // lastConn = socket
console.log(srvr);
}); });
}; };
exports.connect = connect; exports.connect = connect;
const send = (body) => { const send = (body) => {
console.log(srvr);
// connections.forEach((socket, index) => { // connections.forEach((socket, index) => {
// socket.send(body) // socket.send(body)
// }) // })
// if(lastConn) lastConn.send(body) // if(lastConn) lastConn.send(body)
server.clients.forEach(c => { srvr.clients.forEach(c => {
if (c && c.connected) { if (c && c.connected) {
c.send(body); c.send(body);
} }

2
dist/api/utils/socket.js.map

@ -1 +1 @@
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../api/utils/socket.ts"],"names":[],"mappings":";;AAAA,gCAA+B;AAE/B,8BAA8B;AAC9B,4BAA4B;AAE5B,oBAAoB;AACpB,IAAI,MAAW,CAAA;AAEf,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,EAAE;IACzB,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,cAAc,EAAC,IAAI,EAAE,CAAC,CAAA;IAE9D,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;IAE9C,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE;QAC/B,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;QAC9C,gCAAgC;QAChC,8BAA8B;QAC9B,oBAAoB;IACtB,CAAC,CAAC,CAAA;AAEJ,CAAC,CAAA;AAmBC,0BAAO;AAjBT,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE;IACpB,2CAA2C;IAC3C,sBAAsB;IACtB,KAAK;IACL,mCAAmC;IACnC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA,EAAE;QACxB,IAAG,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE;YACnB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACb;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAQC,oBAAI;AANN,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE;IAC1B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAA;AAK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