Skip to content

Commit

Permalink
it's impolite to pee
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed May 14, 2018
1 parent 3cd319f commit 6e3d4f6
Show file tree
Hide file tree
Showing 4 changed files with 1,855 additions and 1,912 deletions.
8 changes: 7 additions & 1 deletion api/index.js
@@ -1,4 +1,4 @@
const {Server} = require('ws')
const {OPEN, Server} = require('ws')

const wss = new Server({port: 3714})

Expand All @@ -22,6 +22,11 @@ wss.on('connection', (ws, request) => {
position (id, x, y, z) {
channels[channel][id] = {x, y, z}
channelUsers[channel].forEach(user => {
if (user.readyState !== OPEN) {
channelUsers[channel] = channelUsers[channel].filter(user =>
user.readyState === OPEN
)
}
user.send(JSON.stringify({
type: 'position',
position: [id, x, y, z]
Expand All @@ -35,3 +40,4 @@ wss.on('connection', (ws, request) => {
handlers[type](...data)
})
})

0 comments on commit 6e3d4f6

Please sign in to comment.