From 52be033500b29e361949bf3333aeaba26cb1e58c Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Wed, 15 Jul 2020 11:24:36 -0700 Subject: [PATCH] fix --- api/utils/socket.ts | 24 +++++------------------- dist/api/utils/socket.js | 19 +++++-------------- dist/api/utils/socket.js.map | 2 +- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/api/utils/socket.ts b/api/utils/socket.ts index e609f34..35ff695 100644 --- a/api/utils/socket.ts +++ b/api/utils/socket.ts @@ -2,19 +2,14 @@ const socketio = require("socket.io"); let io: any -function connect(server) { +export function connect(server) { io = socketio(server); io.on('connection', client => { console.log("=> [socket.io] connected!") - client.on('event', data => { /* … */ }); - client.on('disconnect', () => { /* … */ }); - setTimeout(()=>{ - client.emit('message','wazzup') + send('testing....') },3000) - // io.sockets.send('{"try":"try"}') - // client.send('{"try":"try"}') }); io.on('error', error => { @@ -22,19 +17,10 @@ function connect(server) { }) } -const send = (body) => { - // srvr.clients.forEach(c=>{ - // if(c) c.send(body) - // }) - io.sockets.send(body) +export const send = (body) => { + io.sockets.emit('message',body) } -const sendJson = (object) => { +export const sendJson = (object) => { send(JSON.stringify(object)) } - -export { - connect, - send, - sendJson -} diff --git a/dist/api/utils/socket.js b/dist/api/utils/socket.js index 05f2acd..97801fe 100644 --- a/dist/api/utils/socket.js +++ b/dist/api/utils/socket.js @@ -6,28 +6,19 @@ function connect(server) { io = socketio(server); io.on('connection', client => { console.log("=> [socket.io] connected!"); - client.on('event', data => { }); - client.on('disconnect', () => { }); setTimeout(() => { - client.emit('message', 'wazzup'); + exports.send('testing....'); }, 3000); - // io.sockets.send('{"try":"try"}') - // client.send('{"try":"try"}') }); io.on('error', error => { console.log(error); }); } exports.connect = connect; -const send = (body) => { - // srvr.clients.forEach(c=>{ - // if(c) c.send(body) - // }) - io.sockets.send(body); +exports.send = (body) => { + io.sockets.emit('message', body); }; -exports.send = send; -const sendJson = (object) => { - send(JSON.stringify(object)); +exports.sendJson = (object) => { + exports.send(JSON.stringify(object)); }; -exports.sendJson = sendJson; //# sourceMappingURL=socket.js.map \ No newline at end of file diff --git a/dist/api/utils/socket.js.map b/dist/api/utils/socket.js.map index ee69938..c7d4ba2 100644 --- a/dist/api/utils/socket.js.map +++ b/dist/api/utils/socket.js.map @@ -1 +1 @@ -{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../api/utils/socket.ts"],"names":[],"mappings":";;AAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEtC,IAAI,EAAO,CAAA;AAEX,SAAS,OAAO,CAAC,MAAM;IACrB,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEtB,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE;QAC3B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;QACxC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,GAAW,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE,GAAW,CAAC,CAAC,CAAC;QAE3C,UAAU,CAAC,GAAE,EAAE;YACb,MAAM,CAAC,IAAI,CAAC,SAAS,EAAC,QAAQ,CAAC,CAAA;QACjC,CAAC,EAAC,IAAI,CAAC,CAAA;QACP,mCAAmC;QACnC,+BAA+B;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC;AAcC,0BAAO;AAZT,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE;IACpB,4BAA4B;IAC5B,uBAAuB;IACvB,KAAK;IACL,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACvB,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;AAKC,4BAAQ"} \ No newline at end of file +{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../api/utils/socket.ts"],"names":[],"mappings":";;AAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEtC,IAAI,EAAO,CAAA;AAEX,SAAgB,OAAO,CAAC,MAAM;IAC5B,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEtB,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE;QAC3B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;QACxC,UAAU,CAAC,GAAE,EAAE;YACb,YAAI,CAAC,aAAa,CAAC,CAAA;QACrB,CAAC,EAAC,IAAI,CAAC,CAAA;IACT,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC;AAbD,0BAaC;AAEY,QAAA,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE;IAC3B,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAC,IAAI,CAAC,CAAA;AACjC,CAAC,CAAA;AAEY,QAAA,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE;IACjC,YAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAA"} \ No newline at end of file