Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/stakwork/sphinx-relay
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed May 4, 2020
2 parents 9ccb84a + 58008f8 commit c799c46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
18 changes: 11 additions & 7 deletions api/utils/socket.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as WebSocket from 'ws'

let connections = new Map()
let connectionCounter = 0
// let connections = new Map()
// let connectionCounter = 0

let lastConn: any

const connect = (server) => {
server = new WebSocket.Server({ server })
Expand All @@ -10,16 +12,18 @@ const connect = (server) => {

server.on('connection', socket => {
console.log('=> [socket] connection received')
var id = connectionCounter++;
connections.set(id, socket)
// var id = connectionCounter++;
// connections.set(id, socket)
lastConn = socket
})

}

const send = (body) => {
connections.forEach((socket, index) => {
socket.send(body)
})
// connections.forEach((socket, index) => {
// socket.send(body)
// })
lastConn.send(body)
}

const sendJson = (object) => {
Expand Down
17 changes: 10 additions & 7 deletions dist/api/utils/socket.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/api/utils/socket.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c799c46

Please sign in to comment.