Closed youfeed closed 2 years ago
wss subscribe
message:(ws, message, isBinary)=>{ let msg = new TextDecoder('utf-8').decode(message) if(msg =='subscribe'){ ws.subscribe('uuid') } })
trigger notification
.get('/*',(res, req)=>{ app.publish('uuid', 'IsExample'+new Date()) res.writeStatus('200 OK').writeHeader('IsExample', 'Yes').end('Hello there!'); })
result
<!--StartFragment--> IsExampleThu Jun 02 2022 13:24:11 GMT+0800 (China Standard Time) IsExampleThu Jun 02 2022 13:24:11 GMT+0800 (China Standard Time) <!--EndFragment-->
I pushed it once, but the subscriber will get the second message
Did I do something wrong
I found the reason, I typed in the browser /address, the browser will also send a /favicon.ico The request causes a secondary trigger
wss subscribe
trigger notification
result
I pushed it once, but the subscriber will get the second message
Did I do something wrong