-
Content Count
275 -
Joined
-
Last visited
-
Days Won
2
Posts posted by Yaron
-
-
However, the above did not fully solve my problem, it would have been better if there was a way to get the IP from within functions that are called by mars in Server.Resources, otherwise I'm not sure how to connect the IP from Server.Ignition to an action in Server.Resources in a multi-threaded environment.
-
I believe I figured it out, here's how to show a pop-up dialog with the IP address:
In "Server.Ignition.pas" CreateEngine, I added :
FEngine.OnBeforeHandleRequest := function (AEngine: TMARSEngine; AURL: TMARSURL; ARequest: TWebRequest; AResponse: TWebResponse; var Handled: Boolean ) : Boolean begin Result := True; ShowMessage(ARequest.RemoteIP); end;
And also had to add "MARS.Core.URL, Web.HTTPApp" to the "uses" section.
-
48 minutes ago, pietrt said:I do it in the TMARShttpServerIndy.OnConnect, that is a TIdServerThreadEvent = procedure(AContext: TIdContext) of object;
Client's Ip address: AContext.Binding.PeerIP
Pieter
I'm using ISAPI, not Indy for the server-side code, so I can't get the IP the way you suggest.
I'm hoping for a more generic approach that will work in all MARS output modes (stand-alone application EXE, ISAPI, etc)
-
Maybe one of the MVPs knows a way to do this by leveraging the underlying java code? I need the UI to look sleek and a blank white screen transition sorts of gives a clunky vibe.
-
As part of a service I'm writing using mars, I'm exposing a sign-up page for users to sign up to the service.
However, I want to prevent attacks on the service by bots and possibly detect multiple accidental clicks on the submit button.
Right now the way I'm considering doing this is by keeping a list of IP addresses and verifying that only one sign-up per time-frame is allowed.
I have two questions:
1. Using MARS, how do I read the client's IP address?2. Are there other recommendations for defending mars?
- 1
-
4 hours ago, Rollo62 said:Since Rio it has Z-Order for Android too.
I am using Rio, doesn't seem to help with my issue.
-
You should also be aware that disabling hardware acceleration can harshly impact battery usage for your app.
-
I'm not sure you can really disable hardware acceleration as FMX for Android relies on the GPU canvas which is OpenGL hardware accelerated.
But seriously though, OpenGL hardware acceleration has been built into smartphones for well over 5 years, so even old phones have it.
Not to mention you would have to use Delphi v10.2 or older to even support versions of Android older than v5 and you won't be able to upload these apps into the app store because they don't support the Android SDK google is requiring to upload new apps to the store (not to mention the 64bit issue).
-
I also tried having the TWebBrowser visible off-screen by calling "WebBrowser.SetBounds(clientWidth,0,clientWidth,clientHeight)" and then returning it on-screen when the user clicks a button.
On windows it works well enough (no white flash) but on Android I still see it flashing white for a split second.
-
On 10/17/2019 at 3:09 AM, Remy Lebeau said:Or email the RAD Studio beta directly: rad.beta@embarcadero.com
Since I've now reached a point where I must take action, I've done as you suggested, hopefully the process will be speedy.
-
I'm trying to create a smooth UI experience by loading a webpage in the background and only showing it later on when a user clicks a button in the app.
To load the webpage I'm using:
TWebBrowser.LoadFromStrings('<html><body style="background-color:#2f2f2f"></body></html>','');
However, it seems that the webpage is not rendered if TWebBrowser is not visible, resulting in a white page showing up instead of my HTML.
So I figured if this is a limitation, I'll just have TWebBrowser visible and cover it by a TRectangle, however that didn't work either as it seems (at least under windows) that the TWebBrowser control is always on-top.
I also tried to placing the TWebBrowser control into a TPanel to see if that would allow it to be overlaid by other components, but it didn't make a difference.
Finally I tried utilizing the "OnDidFinishLoad" event, but it didn't help either, a white page would still flicker for a split second before the page was rendered.
Is there some other trick I haven't thought of that will allow me to first render the page in the background and only then show it so I don't have a flashing white box appear for a second before the page renders?
-
17 minutes ago, Dalija Prasnikar said:There is ongoing beta open for people on update subscription. You can participate and use it for publishing 64bit app on Play Store.
I'm aware of the beta, but like I wrote above, I would like to avoid wasting an entire work day installing & configuring a beta version of Delphi if the final release is just around the corner.
And if it's not just around the corner then my subscription might end and I'll be stuck with a beta version.
Like I wrote, no good options for me to plan for when no release information is forthcoming.
- 1
-
Just got word from google that my 32bit project that was in beta would not be approved for the extension, not sure if it was because it was in beta or if I requested the extension too late.
It's a shame that Embarcadero couldn't get the extension accepted all the way to the actual release date of v10.3.3.
Now I'm stuck between a choice of two bad options:
1. Waste hours installing a beta version.
2. Wait an unknown period of time with the hope that a release will be out soon.
All this while the clock is ticking on my subscription and without the ability to release anything for Android.
- 1
-
I eventually created an auto-executing HTML form and used TWebBrowser.LoadFromStrings() to load the HTML and automatically login.
I even made the login 'pretty' by having the form hidden and showing a logo with a CSS based "processing" animation.
The end result looks smooth & professional.
-
I'm wondering if there's a release date planned, I hate installing Delphi each time, takes a while to get everything re-configured on a clean install and doing in-place upgrades has been hit & miss for me.
-
Even though I have a subscription, I did not receive an invitation and now I have a quick Android project that I wanted to beta-test through the play store and... impossible.
While this is a small hurdle now, there are projects that are due in a month or two that I simple can't release, it doesn't seem like google is accepting exemptions on new projects.
- 1
-
I'm doing something similar and encountered some of the same issues.
1. Since ISAPI is a DLL, did you add "IsMultiThread := True;" to let the memory manager know this DLL is using multiple threads (otherwise you can get random-seeming crashes)?
2. I'm not sure your logging code is thread safe, it might be useful to add a critical section to your log writes.
3. There should be no problem using global read-only variables across threads as long as these variables are not classes that do things in the background.
4. If you're accessing a database, make sure to use connection pooling.
5. Do you get a ~90sec freeze when trying to stop the application pool? Make sure to terminate the ISAPI dll correctly.
This is my original thread in which the nice people of this forum helped me identify some of these issues:
-
15 minutes ago, TomDevOps said:Now I don't get this - why do you want to login this way? Why you do not want to use REST and login that way? I do not know if WebView allow to execute your own JavaScript - if so, you could pass credentials to the form this way and then call submit, but again, I would not do this way.
I try to understand your architecture and design choices, can you elaborate, please?
I believe I might be able login by using LoadFromStrings() to feed the html form and auto-activating JS to TWebBrowser with the form's action set to my login url, which will bypass the need to actually modify the html content.
-
3 minutes ago, TomDevOps said:I think I know what you want to achieve, I understand that you want to have HTML/CSS/JS to avoid designing for each platform, so make everything in React, then your web-app and mobile-app can share HTML/CSS/JS stuff 🙂
If React is not an option, then use REST for communication and WebView for displaying the results only, this is what I did for one of the app.
I have already written a Delphi ISAPI DLL that hooks into the microsoft IIS server and outputs HTML/JS/CSS. That part is done and working well in all browsers.
Now, for convenience I would like to create a separate Android app (using Delphi) that uses the TWebBrowser component to open the web server's URL and automatically log-in by filling in the html form fields (user/pass) and press the "submit" button.
With this second part I'm struggling since I don't know how to get to the HTML content displayed by the TWebBrowser component and how to trigger the form's "submit" button.
-
7 minutes ago, TomDevOps said:Should not you use ReacjNative then instead of FireMonkey?
I'm not sure I understand you, do you mean to write the Android app in ReactNative instead of Delphi?
I don't have any experience with ReactNative, that's why I'm trying to use Delphi to simply wrap the html generated by my back-end code in a TWebBrowser component.
-
21 minutes ago, Remy Lebeau said:A better solution would be to forgo the TWebBrowser frontend altogether and redesign your web app to accept REST requests on the backend server to do the work you need. Then use a standard UI on the client side to display the results as needed.
You would have to check if the underlying platform browsers provide any APIs to automate them in code. VCL's TWebBrowser is a wrapper for Internet Explorer and exposes access to its DOM API. FMX's TWebBrowser does not expose similar functionality.
The Delphi back-end is already rest-based, but the whole point of using HTML/JS for the front-end is to avoid having to design the UI for each platform (web/desktop/android) and rely on CSS to style the UI for every device without having to deal with device resolution/scale within Delphi code.
-
I wrote a web-facing application that uses a combination of javascript/css/html for the front-end and Delphi for the back-end.
I decided to create a simple Android app that would wrap the web application using a TWebBrowser control that automatically navigates to the web application's URL.
The web application's requires a login and once logged in, a token is generated sever-side and then embedded into the html of subsequent server requests for future authentication.
For security reasons, I do not want to store the code used to create the token within the Android app, so the easiest way for me to perform the login would be to automatically fill in the web form fields and simulate a "submit" action.
Searching the web, I only found examples of how to do this using the WinAPI version of TWebBrowser, but I'm trying to write something that will work on Android and possibly iOS, any ideas?
-
You beat me to it, I just found this:
https://mathiaspannier.wordpress.com/2016/07/17/how-to-properly-cleanupshutdown-a-delphi-isapi-which-uses-threads/Which is essentially the same answer, can't close the connection in the finalization section when dealing with ISAPI.
- 1
-
Looks like I'm encountering an IIS issue when using this scheme.
In the ISAPI's DLL's finalization code I call "FDManager.Close" and in IIS, when stopping the application pool associated with the DLL it can take ~60 seconds before I can restart the pool, any ideas?
This is the error I get:
Quote---------------------------
Cannot Start Application Pool
---------------------------
There was an error while performing this operation.Details:
The service cannot accept control messages at this time. (Exception from HRESULT: 0x80070425)
When checking my logs, It doesn't seem to exit cleanly (the debug message that the "DB Closed" does not show up in the log), but there doesn't seem to be an exception, here's the code I use:
Try FDManager.Close; Except on E : Exception do {$IFDEF TRACEDEBUG}AddDebugEntry('Exception disconnecting from DB : '+E.Message){$ENDIF}; End; {$IFDEF TRACEDEBUG}AddDebugEntry('DB Closed');{$ENDIF}
When I run the same code locally as an EXE that handles the HTTP requests, there are no issues, any ideas?
FMX TWebBroweser loading pages in the background
in Cross-platform
Posted
How does Flutter relate to Delphi?