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
import{uint8ArrayToUtf8}from'pack-bytes-to-utf8'constbytes=newUint8Array(Buffer.from('0xaa344...64f456','hex'))// Messages in the event stream are separated by a pair of newline // characters, so we exclude the line break characters.//// Excluded characters will be replaced with double-byte characters.constexcludeCharacters=newSet([0xA,0xB,0xC,0xD,0xE])conststr=uint8ArrayToUtf8(bytes,excludeCharacters,)app.get('/sse',(req,res)=>{res.setHeader('Cache-Control','no-cache');res.setHeader('Content-Type','text/event-stream');res.setHeader('Access-Control-Allow-Origin','*');res.setHeader('Connection','keep-alive');res.write(`data: ${str}\n\n`)})