Why use socket.broadcast.emit function over socket.emit - websocket

I know what the difference is the broadcast function sends an event to everyone but the client who caused it and the casual emit sends it to everyone. I don't see why someone would use it. Thank You!

io.sockets.emit will send to all the clients.
socket.broadcast.emit will send the message to all the other clients except the newly created connection.

Related

Catch a swift_TransportException

I'm receiving a lot of "Swift_TransportException: Connection could not be established with host ..." on my slack channel. Everything seems to work fine and the mail service is doing its job. I don't want to receive this certain message on my slack. Can I use $dontreport to help prevent receiving this message? If so, can you please help me out? Is there anyway to catch the exception and exclude it from slack?
(Laravel 7)
Thank you in advance

How to send a message when the user is leaving the page using SignalR?

I'm working on a chat room program using ASP.NET, I have made a 'user has joined the chatroom' message, but how would I send a message when the user leaves the page? I tried looking through the network logs, but I can't see any extra messages getting sent through the WebSocket.
This will be tough and inaccurate because there is really no guarantee that you will get notified that the user has disconnected. But there is an onDisconnect event that you can listen for, but in all honesty, I would use a disconnect button and use that to do what you need to do, it would be more consistent, as the disconnect is not reliable (at least the last time I used SignalR, which was like version 1.x)
Nevermind, I've found out about window.onbeforeunload using JavaScript. Though it's not 100% consistent, it's more consistent than I expected.

user receiving same message twice from Skype bot

I was trying to send skype-bot message to skype-user using REST API in nodeJs, but user receives bot-message two times of that single message. I am sending the message with HTTP POST request only single time using a single activityId. Is there any way to control duplicate messages? what can be the reason behind this?
I have gone through this Receiving the same message twice
Can anyone please like to help finding the issue?
[No sdk or other library is used ]
I have found the issue. I was subscribing redis to read message and deliver to user. I found that it was happening twice[one in my app uploaded to server and another in my local machine]. Now resolves. Thanks !

Using socket.io rooms in treeline using sockets machine pack

I am using sockets machine pack in treeline to subscribe and broadcast messages to particular rooms.
But, i am struggling to get it running by subscribing to a room and sending messages to a particular room. As, when using 'join room' machine. it asks for unique socket ids and whenever i try to get the socket ids from 'getRequestingSocketId' it throws a 500 error. Any help would be deeply appericiated!
I created two routes:
POST /subscribe
POST /senddata
To subscribe to a room
I pass a parameter {roomid: 'room'} with the url /subscribe to subscribe the user to the 'room' room. It asks for a unique socket id here, but when i use 'getRequestingSocketId' it throws the 500 error, when calling the api.
and /senddata is used to send data to that particular room later, here: 'room' room
P.S. I used a common event name to try to send the data
Can you please help me with how to setup socket subscriptions to send data using treeline please ?
Thank you!

In gsm modems, how to inform when a new message has been received (Interruptly) using at commands like CNMA or CNMI?

I'm developing a winform program in which, I need send and receiving SMS messages, I have no problem in sending SMS, but i don't know how to inform when a new message has been received in a gsm modem? I wanna have an acknowledgement like an interrupt or event, when a new message has been received. As far as I know i should work to at+CNMI or at+CNMA, but unfortunately i cant find an example for those.Furthermore I wanna know how to get delivery message or how to handle that? Thanks in advance.
Depends on device type you are using. Use AT+CNMI=? to see all possible options your device supports.

Resources