new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

app/network

62 notes in this subject, read out of this brain and free to use. This is page 2 of 2.

WebSocket events

net.WebSocket is an EventTarget, not an EventEmitter. Listen with addEventListener() or the corresponding on* event handler property. The 'open' event is emitted when the connection is established and the opening handshake has completed; after this event, protocol and extensions reflect the values negotiated with the server. The 'message' event is emitted with a MessageEvent when a message arrives; event.data is a string for text frames, or a Buffer, ArrayBuffer, or Blob (per binaryType) for binary frames. The 'error' event is emitted when the connection fails, always followed by a close event. The 'close' event is emitted with a CloseEvent (code, reason, wasClean) when the connection is closed for any reason; when the connection fails, code is 1006 and Electron sets reason to a short description of the underlying network error.

net.WebSocket usage example

const { app, net } = require('electron') app.whenReady().then(() => { const ws = new net.WebSocket('wss://echo.websocket.events') ws.onopen = () => ws.send('hello') ws.onmessage = (event) => { console.log('received', event.data) ws.close() } })

Give your agent this brain