| const signalPeerStop = (username) => signal({kind: 'peerInfo', value: {type: 'stop'}, source: username}) | const signalPeerStop = (username) => signal({kind: 'peerInfo', value: {type: 'stop'}, source: username}) | ||||
| const listen = (kind, handler) => addEventListener(kind, handler) | const listen = (kind, handler) => addEventListener(kind, handler) | ||||
| listen('login', ({detail}) => State.username = detail.value) | listen('login', ({detail}) => State.username = detail.value) | ||||
| listen('state', ({detail}) => Object.assign(State, detail)) | |||||
| listen('post', ({detail}) => State.posts.push(detail)) | listen('post', ({detail}) => State.posts.push(detail)) | ||||
| listen('peerInfo', (e) => onPeerInfo(e)) | listen('peerInfo', (e) => onPeerInfo(e)) | ||||
| const doNotLog = new Set(['login', 'post', 'peerInfo']) | |||||
| const doNotLog = new Set(['login', 'state', 'post', 'peerInfo']) | |||||
| /* | /* | ||||
| * | * | ||||
| State.websocket.onmessage = (e) => { | State.websocket.onmessage = (e) => { | ||||
| const message = JSON.parse(e.data) | const message = JSON.parse(e.data) | ||||
| if(message.online) { | |||||
| State.online = message.online | |||||
| } | |||||
| if(!doNotLog.has(message.kind)) { | if(!doNotLog.has(message.kind)) { | ||||
| console.log(message) | console.log(message) | ||||
| } | } |