You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Demo server for message-meta * * Run: node server.js * * - attaches message-meta to sockets and echoes messages with meta */consthttp=require('http');constcreateWebSocket=require('../../../core');const{ createMessageMeta }=require('../index');constmm=createMessageMeta({perConnectionSequence: true});constserver=http.createServer();const{ registry }=createWebSocket.attachServer(server,{onConnect(ws,req){mm.attach(ws);ws.on('message',(ev)=>{constparsed=mm.parseIncoming(ev.data||ev);if(parsed.ok){// echo back with same metaconstframe=JSON.stringify({echo: parsed.payload,__meta: parsed.meta});ws.send(frame);}else{ws.send(JSON.stringify({error: parsed.reason||'bad'}));}});}});server.listen(8096,()=>console.log('message-meta demo on ws://localhost:8096'));