eldelshell
Joined 12 years ago
Joined 12 years ago
You need to implement a server-side heartbeat feature.
You need to handle the close event from EventSource and be able to reconnect.
Tabs can be problematic. When you subscribe, you use a URL with a nominal ID to identify the client. For example, on a chat app, you would use /api/sse/userA/subscribe
Problem is, if userA starts opening tabs, each tab creates a new subscription for userA so you need to randomize each connection (userA-UUID).
If you don't use a nominal id, the server won't know to which subscriber to send the data and you don't want to broadcast all your chats.
I've used the Broadcast channel API in conjunction with SSE to have only one tab handle the SSE connection, and broadcast incoming SSEs to the other tabs which also reduces the number of connections to the server to one.
On the server it's also a PITA because not all instances/pods have the subscribers list. The way I've found to solve this is with clustering the instances with Hazelcast or Redis or a MQ.
But once you figure out all this, SSE works quite well.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...
Also, SWE is a highly movable profession, where being more than 5 years on the same place is unusual. So every ~5 years you have to polish your CV, grind LC and basically restart learning all computer science concepts you haven't used in those ~5 years, without feeling burnout or dismay.
With the US dollar, Euro and some others, the world is your casino (following the comparison) and you can trade all of them. Same with gold and silver (although this are a bit harder to trade).
Hell, try to pay a taxi in Djibouti, Sao Paolo or Islamabad with a BTC or USD and see which they'll accept and which will get you kicked out.
This is the best way to understand NFT.