Hi All and Happy new Year.
Over the last couple weeks I have been learning about akka and akka streams and am very excited about their potential for various projects that I work on, specifically the non-blocking and stream oriented features of akka and play. One use case that i’ve been looking at is using akka streams for handling web socket based applications. In particular i’ve been looking at the play-socket.io library and its examples.
I’ve been looking at this example on the play-socket.io github repo:
And I cannot figure out how the streams/flows are getting wired up, I’ve studied the akka streams doc in details and understand how Hubs etc work, but cannot follow what is happening in that example.
This is what I can understand:
In Line 94 a flow is created such that each message that enters the flow will be handled in a different way, for instance Chat messages pass right through to “via” part which is the Merge/Broadcast channel for the play-socket.io namespace. Join messages, will spin off the creation of a new flow that specifically deals with Join and Leaves… and is materialized in Line 100.
This is where I get lost, how is this
broadcastSource related to anything else, it just seems to get materialized in isolation in the map function.
And even more confusing, what on earth is happening here. Why is the
source of the ultimate Merge/Broadcast channel being set to the previously mentioned
broadcastSource in the materializer combiner function. Same for
mergeSink, why is it being set to
sink, While the combiner function isn’t returning anything.
I have a lot of experience as a Java developer and have studied that example and akka streams in detail, but this example is making me feel really dumb, I know this is probably a question for the play-socket.io team, but can anyone shed any light light on how this example is working.