cyracks Posted November 24, 2021 Share Posted November 24, 2021 Hello is it possible to create multithreaded REST server with UniGUI ? I have read it is not build for that and that it could be done in ServerModule, but that is a singleton and probably not the right approach. Is is possible to "remove" main form and use session event TUniMainModule.UniGUIMainModuleHandleRequest to handle requests and set response ? Quote Link to comment Share on other sites More sharing options...
Jean-Marc Kiener Posted November 24, 2021 Share Posted November 24, 2021 use dmvc (https://github.com/danieleteti/delphimvcframework) instead. It is made exactly for your case. 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 24, 2021 Share Posted November 24, 2021 10 minutes ago, cyracks said: is it possible to create multithreaded REST server with UniGUI ? I have read it is not build for that and that it could be done in ServerModule, but that is a singleton and probably not the right approach. Is is possible to "remove" main form and use session event TUniMainModule.UniGUIMainModuleHandleRequest to handle requests and set response ? Hello, Yes. Using OnHttpDocument and OnHttpCommand events (UniSeverModule). You can search on the forum with these keywords. Quote Link to comment Share on other sites More sharing options...
cyracks Posted November 24, 2021 Author Share Posted November 24, 2021 Jean-Marc: thanks for the tip. I know there are other solutions available, but they all take time to learn and time is something i really do not have. Sherzod: UniServerMoudle is singleton so no multithreading "out of the box". I do not want that multiple request are in one queue, all http requests should be executed immediately. Quote Link to comment Share on other sites More sharing options...
picyka Posted November 24, 2021 Share Posted November 24, 2021 TMS XData documentação | Documentação TMS XData (tmssoftware.com) Quote Link to comment Share on other sites More sharing options...
Tokay Posted November 24, 2021 Share Posted November 24, 2021 48 minutes ago, cyracks said: UniServerMoudle is singleton so no multithreading "out of the box". The UniServerMoudle has multithreading out of the box of cause. Each of the connections works in the different thread. Quote Link to comment Share on other sites More sharing options...
cyracks Posted November 24, 2021 Author Share Posted November 24, 2021 TUniGUIServerModule Class Quote Every uniGUI application requires one server (its ServerModule as a global singleton), one session (represented by its MainModule) I would like to work in MainModule where thread is already made and database connection is separate from other threads, but I do not know how to get rid of the "form(s)". How to gain control over what is returned to client, so that only relevant data is sent ? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted November 25, 2021 Administrators Share Posted November 25, 2021 Please note that sessions and threads are not same things. Each session has a dedicated connection provided that Connection component is placed on MainModule. However, sessions can be served by different threads at different times. When a request is received it can run in any thread and it is not guaranteed that it is the always same thread for a particular session. What uniGUI governs is that a session will not be accessed by multiple threads simultaneously. Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted November 26, 2021 Share Posted November 26, 2021 UNIGUI AND FASTREPORT Sparks from collision 3 Quote Link to comment Share on other sites More sharing options...
cyracks Posted November 26, 2021 Author Share Posted November 26, 2021 8 hours ago, 风吹小机机 said: Great, could you please share the code ? Quote Link to comment Share on other sites More sharing options...
Stemon63 Posted November 26, 2021 Share Posted November 26, 2021 11 hours ago, 风吹小机机 said: UNIGUI AND FASTREPORT Sparks from collision What a beautiful tool!! Quote Link to comment Share on other sites More sharing options...
araujoadanr Posted January 13, 2022 Share Posted January 13, 2022 You are a genius Quote Link to comment Share on other sites More sharing options...
Stemon63 Posted January 17, 2022 Share Posted January 17, 2022 On 11/26/2021 at 7:10 AM, 风吹小机机 said: UNIGUI AND FASTREPORT Sparks from collision Please tell us more on this project!! It's wonderful!! You sell it? Thanks Quote Link to comment Share on other sites More sharing options...
jrp Posted March 27, 2022 Share Posted March 27, 2022 On 11/25/2021 at 1:13 AM, cyracks said: TUniGUIServerModule Class I would like to work in MainModule where thread is already made and database connection is separate from other threads, but I do not know how to get rid of the "form(s)". How to gain control over what is returned to client, so that only relevant data is sent ? Hi cyracks, I want to do something like what you wanted to do: work in MainModule and get rid of the forms. Have you figure out how to do it? Quote Link to comment Share on other sites More sharing options...
cyracks Posted March 31, 2022 Author Share Posted March 31, 2022 Yes but not with Unigui but with IntraWeb. But it would be really good if something like that would be possible in UniGui. I assume that not much effort would be needed to implement this functionality - sooner or later you have to implement API in your web application. Instructions for IntraWeb NOT UniGui unit ServerController; ... initialization TSQLtoHTTPServerController.SetServerControllerClass; with THandlers.Add('', '/', TContentHTTP.Create) do begin CanStartSession := True; RequiresSessionStart := False; end; TContentHTTP unit _uSQLApi; interface uses Classes, IW.Content.Base, HTTPApp, IWApplication, IW.HTTP.Request, IW.HTTP.Reply, System.DateUtils, SysUtils, System.StrUtils, System.SyncObjs; type TContentHTTP = class(TContentBase) protected hRequest: THttpRequest; ... end; implementation uses ServerController, IW.Content.Handlers, IWMimeTypes; constructor TContentHTTP.Create; begin inherited; mFileMustExist := False; end; function TContentHTTP.Execute(aRequest: THttpRequest; aReply: THttpReply; const aPathname: string; aSession: TIWApplication; aParams: TStrings): boolean; begin Result := True; aReply.WriteString('test'); // CHECK MULTITHREAD - 10 simultaneous requests must complete in 3 seconds not 30 seconds Sleep(3000); aSession.Terminate; end; end. 1 Quote Link to comment Share on other sites More sharing options...
jrp Posted April 2, 2022 Share Posted April 2, 2022 That's cool cyracks. I hope someone will show us how to do it with UniGUI. Quote Link to comment Share on other sites More sharing options...
TimKieu Posted October 25, 2022 Share Posted October 25, 2022 Based on Indy HTTP/1.1, Delphi RESTful servers are almost low performance. This case JavaSE-based frameworks win. Let take a look at: TechEmPower blog AFAK, there may be only EsegeCe websocket SDK with HTTP/2 Indy ready for your high performance REST servers using with UniGUi. But it is commercial license. Quote Link to comment Share on other sites More sharing options...
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.