Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
2 windows 2nd not getting broadcast
I have 2 different mdichilds open under the one MDI Menu. One Window sends an OLE.Broadcast the second window is not receiving it. All OK when run in separate MDi. i.e. 2 copies of app running.
There is something in the back of my mind about seeing something about a 'token' id being generated not being unique and thus some are getting 'lost'. (Also asking this question is familiar(sorry))
There is something in the back of my mind about seeing something about a 'token' id being generated not being unique and thus some are getting 'lost'. (Also asking this question is familiar(sorry))
Comments
Are you sure that each control is connecting to the SRP SyncServer? Are you qualifying each control to listen for the OnMessage event?
The directconnect control is on the mainmenu (mdi) . There are 2 windows open. One window sends message (to the directconnect control on the mainmenu) for the other window to 'pickup'. The other window is not picking up, but is, if open in another open copy of the mainmenu.
You didn't answer my questions.
'..each control', yes, ....you mean the directconnect(of which there is only 1)?
There is only 1 control that is on the mainmenu, so, yes as it works when on separate PCs on network.
The mainmenu directconnect onmessage event sends a post_event omnievent to all the open windows as was suggested elsewhere in this forum.
But worried I am not explaining properly as your questions are not matching my problem.
If you think that this should work under this situation, then I will put some debugging in to see what is/isnot happening.
If you do understand my senario, how do you suggest this should be setup.
In the meantime I will see if I can find the posting re how to do (I think it might have been Aaron's)
https://forum.srpcs.com/discussion/569/oi-crashes-on-a-network-system/p2
Aarons suggestion was here at the bottom:
https://forum.srpcs.com/discussion/569/oi-crashes-on-a-network-system/p1
Let's start over since it is clear that there are some misunderstandings and perhaps false assumptions on my part.
Is it now the case that you only have one SRP DirectConnect ActiveX control embedded within the entire application?
If so, does this control lives on your MDI Frame?
In your original post, you said one window sends the broadcast but the other window does not receive it. This is where I am confused. How exactly does the "one window" send the broadcast? Are you invoking the Broadcast method of the SRP DirectConnect control that is on the MDI Frame or are you using the SRP DirectConnect COM object?
How exactly does the "second window" receive the broadcast? If there is no SRP DirectConnect ActiveX control on this window, how does it get notified of a message?
My understanding is that you are trying to use the SRP DirectConnect control as a way for the same OI application to talk to itself. Is that correct? If so, I suggest this is overkill. The SRP DirectConnect control (along with the SRP Sync Server) was designed so that different instances of OI can talk to each other (peer-to-peer). I would recommend a simpler and more direct way, such as Send_Event(), for one OI form to talk to another OI form within the same running application.
rv= Send_Message(MAINMENU:".OLE_DIRECTCONNECT", "OLE.Broadcast", Message))
MAINMENU:".OLE_DIRECTCONNECT:case OleEvent _eqc 'onmessage' if cp _eqc 'OLE_DIRECTCONNECT' then call mortuary_funeral_directconnect_onmessage(@Window,Param2) end
mortuary_funeral_directconnect_onmessage:
OpenMDIs=utility("OBJECTLIST",MenuName,'WINDOW') count=dcount(OpenMDIs,@fm) for x = 1 to count call post_event(OpenMDIs<x>,"OMNIEVENT",MessageData,'onmessage') Next x
2nd window 'OMNIEVENT:
begin case case param2 _eqc 'onmessage' PassedParam=param1 gosub ProcessOnMessage End Case
But that window can also be open by itself in another PC , so I do have to do the broadcast for the second window.
I don't see it being called overkill, more like 'it cant work that way', so you are saying I have too take into account the possibility it is open on this PC and do a send event.? How do I tackle that - - stab in the dark send_events.
What about when 2 instances of the menu running on the same PC, how do you then do it for that, which I assumed should work and dont see why it cant and , would a send_event work?
Just to be clear, I am not saying don't call the Broadcast method. As you noted, other instances of OI will need the OnMessage event to sync up. So you are correct there.
To work around this, in your code that sends the Broadcast method, also call this:
call mortuary_funeral_directconnect_onmessage(@Window,Param2)
That will simulate what your form would do naturally if it actually received the OnMessage event. Two instances? Do you mean the main menu is a multi-instance form or are you referring to two instances of the application (i.e., two OpenInsight sessions on the same PC)?
Are you saying that for correct implementation, that each window should have a directconnect ole and the onmessage should be sent to those.
call mortuary_funeral_directconnect_onmessage(MAINMENU,Param2)
Thank you so much
I don't have this scenario at the moment but I had coded for the possibility. Now I know not to try and implement it.
As I said, I haven't implemented the two directconnect controls as yet, nor do I have any immediate plans to but I think where my mind was headed during the initial implementation was this.
I have a directconnect setup for use with a very specific purpose, sending notifications between users, ie the onMessage results in a popup on the desired recipients screen. The most common use of this though is for notification of the completion of batch processing. For example, a user runs a report that is known to take an extended period of time to run. They can opt to batch the report so they can continue with their work. The report gets processed in due time on the server, a file gets created, then the user receives a notification/popup that the report is finished and a link to the actual report.
The thinking behind the second directconnect control was if I had a need to keep other things in sync for example perhaps similar to what Barry is doing or like would be the case with the SRP Schedule. A separate directconnect control. A syncserver running on the server but with a different port. That way notifications could be handled through one directconnect/syncserver and synching could be managed via another combination of the two.
If the OI crashing issue gets sorted do you think there would be any benefit to making the distinction or would it perhaps be overkill?
For the project I'm currently working on, I created a service module to facilitate the messaging. Two of the services are SendRequest and SendResponse (borrowing from HTTP request and response messaging). Each service has two arguments: Type and Body. A JSON object is created with the information packaged and then sent out to the SRP Sync Server. In fact, I don't even use the ActiveX control on the form to broadcast the message. I use the COM object so that my messaging service can be called from anywhere at anytime.
Then the OnMessage event handler unpacks the JSON object and quickly checks to see if this is a Request or a Response. The event handler then ignores it if needed or handles it as appropriate. I think your situation could work well in this context since you can add new requests and responses at will.
I am following a similar concept but I didn't think to use JSON as the message, probably because at the time I wasn't familiar enough with it. I simply made a string with delimiters. Works but is limited in it's capabilities.
I use both the activex and the COM object depending on the source of the notification.
It will require a bit of a rework but worth it in the end I reckon.
BTW, to keep things safe, I always BASE64 encode the content I am passing in through the Body argument and then decode it on the receiving end.