Browse Source

Notify join leave others

master
Roderic Day 5 years ago
parent
commit
a25209dbf1
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      pico.js

+ 3
- 3
pico.js View File

delete detail.kind delete detail.kind
Object.assign(State, detail) Object.assign(State, detail)
}) })
const doNotLog = new Set(['login', 'state', 'post', 'peerInfo', 'join', 'leave'])
const doNotLog = new Set(['login', 'state', 'post', 'peerInfo'])
/* /*
* *
* UTILS * UTILS
if(message.online) { if(message.online) {
const difference = (l1, l2) => l1.filter(u => !l2.includes(u)) const difference = (l1, l2) => l1.filter(u => !l2.includes(u))
difference(message.online, State.online).forEach(username => { difference(message.online, State.online).forEach(username => {
if(username === State.username) return
signal({kind: 'post', ts: message.ts, value: `${username} joined`}) signal({kind: 'post', ts: message.ts, value: `${username} joined`})
signal({kind: 'join', username: username})
}) })
difference(State.online, message.online).forEach(username => { difference(State.online, message.online).forEach(username => {
if(username === State.username) return
signal({kind: 'post', ts: message.ts, value: `${username} left`}) signal({kind: 'post', ts: message.ts, value: `${username} left`})
signal({kind: 'leave', username: username})
}) })
} }



Loading…
Cancel
Save