I have instantiated an instance of a MySS::ServerSocket on my MainWindow.
AddSocket instantiates a MyTCPSocket returns it as a TCPSocket
MyTCPSocket class declares an event MyDataReceived, which it ‘raises’ (?) after the TCPSocket dataAvailable event is done.
How do I receive the MyDataRecieved event on my MainWindow? Who got the event?
Function AddSocket() Handles AddSocket as TCPSocket
Dim ret As MLLP_HL7SegmentFactory = New MLLP_HL7SegmentFactory(mCurrentSocket)
mCurrentSocket = mCurrentSocket + 1
Return TCPSocket(ret)
End Function
Have a close look again at Tim’s ScreenShot - and then at the one of your project structure.
Assuming you would add an MLLP_HL7SegmentFactory to your MainWindow, you could then add the EventHandler Message to MLLP_HL7SegmentFactory1 there.
You obviously can’t add the EventHandler Message to your MLPServerSocket1 on your MainWindow, because your MLPServerSocket does not define a (custom/own) EventDefinition Message.
Uff, a bit too tricky to explain in plain text. And different approaches that would be possible.
One possible way:
Start by adding EventDefinition Message to your MLLPServerSocket
When instantiating your MLLP_HL7SegmentFactory TCPSocket’s in there
AddHandler to receive their Message’s
likely you then want to forward their received messages by RaiseEvent Message
So the original Message is created in TCPSocket → listened by ServerSocket → forwarded to EventDefinition on ServerSocket → which can be added as an EventHandler on the Instance of your ServerSocket in your MainWindow to get the messages there.
Note: Code is quick&dirty, just to show the two mentioned approaches. Both could obviously be improved or done differently. The goal was really just to show the “flow” how a “Message” could go from TCPSocket to Window.
Run the example and click on the two Buttons (which opens the Browser at the listened ports, Sockets are writing a silly simple text to the browser).
And I hope the example shows how “Messages” in the TCPSockets are finally showing up on the Main Window.