B4J Question Webview per Session/Client at JServer

Magma

Expert
Licensed User
Longtime User
Hi Fam...

I am creating a project... a server with API... that will be used from clients/browsers/apps...

Every time someone using API login https://atmyserver/myapi/login will create a webview for specific session (is it possible?)
thinking to do it something like that:
B4X:
    Public WebViewMap As Map
    WebViewMap.Initialize
....
    Dim wv As WebView
    wv.Initialize("")
    WebViewMap.Put(idofsession, wv)
...when second session will get new idofsession:
    Dim wv As WebView
    wv.Initialize("")
    WebViewMap.Put(idofsession, wv)

With running javascript with javaobject and getEngine... will use dom elements to login...

My silly question is that.... every webview using exclusive cookies? and if not? how to push it use different cookies - and how to have all these webviews open and using them the same time/concurrency without problems ?

Need at any API call - to login at every webview, browse pages, extract data or can split those between api calls ? what do you think ?
or at specific time session/webview will logout me as in standard browser?
 

Magma

Expert
Licensed User
Longtime User
Well.. no.. let me take it from start..

There is one public website app that is not offering api.. and need to make it simpler for every client .. this is I am doing with a local b4j app... but I need to make it as a web service..
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
You should use jServer for this.
Yes I will serve clients via jserver... but how I will connect for every client at different web view to connect at this public site (not mine, gov) - login with credentials and browse pages.. for them...?

Actually my job is to automate some things... so with one move from their side ..my server will do 10 things.. but the same time for many others too...

Also I will have many works split at handles that will reuse their sessions... how to achieve that ?
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
I will try to visualize - to understand it better...

This is a public gov site - any user can use... (there are services not offering API - so need to login and make some selections and get some pdf or set appointments and etc):
1759136979898.png


I ve managed with webview and using dom elements to automate some things - without the user need to make - many selections and etc... minimzed the time of using...
1759137057704.png


My question is not if i will use jserver ... i know i will use it.. is has to do... how i will have many webviews open the same time without mixxing the "cookies" of different user sessions... is it possible... or need something different to achieve that ?
1759137172187.png

All these (not just 6, but potentially hundreds) will be WebViews opened concurrently, and they will not be managed by a single jServer handle. Instead, the work will be distributed in jServer by opening sessions and closing them when the user signs out from my web service.


This app/server will be a middleware to automate some things for end user.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Assume the public server returns an access token for each login, you can store all the tokens and then make the subsequent requests.
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Assume the public server returns an access token for each login, you can store all the tokens and then make the subsequent requests.
no ... the public "webpages" are just webpages (no api) as i said...

Check the visuals to understand.... a guy just browsing a site with his username/password.. clicking there... there... changing - adding some things... logouts...

no api

* I ve managed locally with b4j - created a program... automate all these... using dom - elements - clicking there and there... and return to guy the pdf needed... but locally - now need to make that "a service" - my web service...
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
There are two thing making me afraid for the version i want to make...

1. webviews... can i have many, one per user/sessionuser - keep them open, and use them between handles without mixed with other webviews ?
2. my method is something like webextracting, like a bot, a) is it safe? b) is it illegal ?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
yes - but i am using webview - and soon webviews... how to use those cookies ?
Have you thought not to use Webview?
I think it is a bad idea and make it more complicated.
Maybe it is possible with just OkHttpUtils.

1759145955846.png
 
Last edited:
Upvote 0
Top