Ask for help with socket usage questions?

add the code directly as follows:
let isFirst1 = 1;
sockets.forEach ((socket) = > {

if(isFirst1 == 1) { 
    lightLog.info( "bonus" ,dataArr);
    socket.emit( "bonus1" ,dataArr);
    socket.broadcast.emit( "bonus1" ,dataArr);
    isFirst1 = 0;
}else{
    lightLog.info( "" );
}

}); the purpose of
code is to push only once, but the problem now is that when using the isFirst1 flag, it is only sent to yourself and does not broadcast the event. At this time, the event cannot be sent. When the isFirst1 flag is removed, it is OK, but it will be pushed many times at this time. What should I do if I only want to push it once?!?.
in addition, I found that only the broadcast function is useful, socket.emit this seems to be useless, I don"t know why?

Dec.27,2021
Menu