Freeman35 Posted April 29 Posted April 29 Hello, How to use OnBroadcastMessage event on TUniFrame and What is the difference between BroadcastMessage and BroadcastMessageSessions? Quote
Sherzod Posted April 29 Posted April 29 17 minutes ago, Freeman35 said: What is the difference between BroadcastMessage and BroadcastMessageSessions? Hello, BroadcastMessage → sends to all sessions BroadcastMessageSessions → sends to selected sessions Quote
Freeman35 Posted April 29 Author Posted April 29 Thank you, 10 minutes ago, Sherzod said: Hello, BroadcastMessage → sends to all sessions BroadcastMessageSessions → sends to selected sessions How to use OnBroadcastMessage event on TUniFrame ? I think only Farshad knows this. Quote
Sherzod Posted April 29 Posted April 29 32 minutes ago, Freeman35 said: How to use OnBroadcastMessage event on TUniFrame ? TUniFrame does not support OnBroadcastMessage because this event belongs to TUniBaseForm. A TUniFrame is a visual container and cannot exist independently; it must be hosted inside a form or another container. Broadcast messages are handled at the session/form level, so they are delivered to forms. If needed, the form can forward the message to its frames... Quote
Freeman35 Posted April 29 Author Posted April 29 TUniFrame = class(TCustomFrame, IUniControlOrdered, IUniControl, IUniControlEx, IUniCoreNotify, IUniLayout, IUniDialogs) private FOwnerWebForm : TUniBaseJSForm; <-- ----------------------------------------------------- TUniBaseForm = class(TUniBaseIntermForm, IUniForm, IUniLayout, IUniControlEx) private mentControl; FWebForm : TUniBaseJSForm; <-- ----------------------------------------------------- procedure TUniBaseJSForm.DoSocketMessage(const Params: TUniStrings); .... If work on this, I thing TUniFrame can get FOnBroadcastMessages RASCore use many TUniFrame etc. Quote
Fred Montier Posted April 29 Posted April 29 Is more simple: uses the PARAM property in the msg broadcasting and you can target and/or tailor whatever you want. Quote
Freeman35 Posted April 30 Author Posted April 30 7 hours ago, Fred Montier said: Is more simple: uses the PARAM property in the msg broadcasting and you can target and/or tailor whatever you want. Yes you rigth. Have to handle message in form. Okay Its can be Main form. But I have to write code for this. check target, it iss created? showed? will sent this to that frame? etc. sent message(s) to them etc. if if TFrame has "OnBroadcastMessages" event just write code in this event. If need. I'm just asking why not TFrame as well, just to simplify the code. If I'm not mistaken, everyone uses TFrame for its lightness. The goal is less code, less overhead. Quote
AlexM123 Posted April 30 Posted April 30 I use PubSub pattern. New frames are registered in a list in the main window. When a broadcast message is received it is forwarded to a registered frame/frames. Quote
Administrators Farshad Mohajeri Posted April 30 Administrators Posted April 30 17 hours ago, Freeman35 said: Thank you, How to use OnBroadcastMessage event on TUniFrame ? I think only Farshad knows this. Not exactly, because frames are just like any other controls in the app. Each form may contain many frames and uniGUI doesn't maintain a list of active frames internally. Quote
Freeman35 Posted April 30 Author Posted April 30 Result: There will be no OnBroadcastMessage in TFrame. Am I understanding correctly? (I use Google Translate, translations can sometimes be incomprehensible.) Quote
Administrators Farshad Mohajeri Posted April 30 Administrators Posted April 30 No. There's no plan to add it because of implementation complexity and other difficulties. OnBroadcastMessage will be supported on main form and other active forms. Maybe you can share your usage scenario and we can make recommendation based on it. Quote
Sherzod Posted April 30 Posted April 30 57 minutes ago, Freeman35 said: Result: There will be no OnBroadcastMessage in TFrame. You can handle the broadcast in the form and forward it to the frame: procedure TMainForm.UniFormBroadcastMessage( Sender: TComponent; const Msg: string; const Args: array of const); begin if Msg = 'update' then MyFrame.RefreshData; end; Since TUniFrame does not support OnBroadcastMessage, the form should act as a proxy. Quote
Freeman35 Posted April 30 Author Posted April 30 23 minutes ago, Farshad Mohajeri said: No. There's no plan to add it because of implementation complexity and other difficulties. OnBroadcastMessage will be supported on main form and other active forms. Maybe you can share your usage scenario and we can make recommendation based on it. Hello, The reason for my insistence is that I use RADCore, and it only uses frames. Even if I find this from the children of the form, it may not work correctly in this respect because it plays with the parents of the frames. I want this to use instead of Firebird Event alerter. I used fbEventAlerter in 2020, there was no OnBroadcastMessage at that time. There is no need to use the same method, the message over the db, moreover, a single value is meaningless now. I will do my work such as chatting etc. between frames (between different sessions). TUniGUISession.FormsList and TUniGUISession.DataModules are available, if you can add TUniGUISession.FrameList to this, I will have done my job. I will prevent any confusion that may arise from the parent. If you say it won't happen, I will have to put a tlist in the mainmodule and create my own list by tuniframe's oncreate and ondestroy. 18 minutes ago, Sherzod said: You can handle the broadcast in the form and forward it to the frame: procedure TMainForm.UniFormBroadcastMessage( Sender: TComponent; const Msg: string; const Args: array of const); begin if Msg = 'update' then MyFrame.RefreshData; end; Since TUniFrame does not support OnBroadcastMessage, the form should act as a proxy. The problem is not being able to create a correct list for Tuniframe. Checking the children of the form is not the right approach, because if the parents are changed, this system will not work correctly. Quote
Administrators Farshad Mohajeri Posted May 1 Administrators Posted May 1 We will try to find a solution for this. Quote
Freeman35 Posted May 1 Author Posted May 1 11 minutes ago, Farshad Mohajeri said: We will try to find a solution for this. Thank you Quote
Fred Montier Posted May 3 Posted May 3 On 4/30/2026 at 4:27 AM, Freeman35 said: Yes you rigth. Have to handle message in form. Okay Its can be Main form. But I have to write code for this. check target, it iss created? showed? will sent this to that frame? etc. sent message(s) to them etc. if if TFrame has "OnBroadcastMessages" event just write code in this event. If need. I'm just asking why not TFrame as well, just to simplify the code. If I'm not mistaken, everyone uses TFrame for its lightness. The goal is less code, less overhead. See uniFrame as a "glorified" panel. Keep a Frame string ID list at parent form level. When parent form receives that messages targeting the particular hosted frame,get the ID and trigger your code towards that frame. Using this, you can target anything in a form as a pseudo onAjaxEvent. Same login to a form handling a chat with many user, and direct messaging to one of them. Keep in mind that RadCore is a solution looking for a problem. I think radcore support team should give you a better solution, if any. If you scale your app, will also scale this problem. Just imagine using this approach with hyperserver. This solution ALSO will not work. Better ask them. See the chat demo and how to handle broadcasting with uniStrings Quote
Freeman35 Posted May 4 Author Posted May 4 Thank you Fred, I solved the problem for myself. Farshad "We will try to find a solution for this." When I wrote it, I ended it so as not to extend the topic. Simple logic, MainForm must be in every project. This means one mainform in each session. TUniFrame.OnCreate adds itself to the list above, and .OnDestroy deletes it. This gives me the Frames list. With TMainForm.UniFormBroadcastMessage, I can send incoming messages to any open uniframe etc. in the osession, wherever I want. regards. private { Private declarations }// It should only belong to this session F_Frame_List: TList<TUniFrame>;// My Frame list Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.