This week's book giveaway is in the NodeJS forum. We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line! See this thread for details.
I'm developing a web app that accepts websocket connections from desktop clients for viewing various areas of a worksite. The relationship between worksites and watching clients is many-to-many, as any given client app may register to watch several worksite areas, and any given worksite area may be watched by several connected clients.
On the server endpoint I chose to implement this relationship using Guava multimap: keys being worksite areas (duplicates allowed), and values being endpoint connections (again, duplicates allowed). This map is declared as a class (static) field.
When a change occurs, serverside, in relation to a given worksite area, I simply use the multimap's get() method to retrieve all the endpoints watching that particular area, and PUSH a notification message out to those clients. So far so good.
The challenge is how to remove from this multimap all entries relating to a client endpoint that subsequently disconnects. I'm wondering whether there might be a better alternative to the below, where I simply iterate through all entries and test each value as to whether it equates to the endpoint that just disconnected.
Everybody! Do the Funky Monkey! Like this tiny ad!
global solutions you can do in your home or backyard