Socket management for in app notifications

Hello, I am using the in-app notification to send a real-time notification to a player when another player attacked him (kind of passive multiplayer). We also use this notification to update the attacked (notified) player stats in real-time. For some reason that I didn’t manage to identify or reproduce yet, it sometimes happens that a player does not receive the notification. this of course then leads to other problems as the player’s local stats are not compatible with the stats on the server. I am suspecting it has something to do with the socket I am opening at the beginning of the sessions and use it to listen to the in-app notification, are you familiar with any similar problem, are there any rules or practices that need to be made make sure the socket is always alive? (Today I am simply creating the socket at the beginning of the session)


@oshribin I think you were able to make progress on this for your game. Do you have code or advice you can share on what approach you used? Are you still stuck on any parts?

Yes, so I was naive and didn’t put error/close listeners on the sockets and did not open a new socket, and so the players did not receive notifications after the socket was disconnected.

The main issue was the fact the socket behaves differently on the unity editor than it would behave on the underlying devices so I didn’t manage to reproduce a socket disconnection. But after adding error and close listeners to the socket, and building to a device. It was pretty straight forward, after a few seconds in the background the socket was closed, and the listener was triggered.

So now whenever I encounter a socket close event I am creating a new one. It is important to pay attention and make sure you do not open multiple sockets.

I have also realized now that I can use the same socket for in-game notifications and for authoritative matches.


That’s perfect @oshribin. Would you be able to open an improvement request on the Unity client SDK and we can work on how to make the socket management more automatic?