B4J Question web apps

elitevenkat

Active Member
Licensed User
Longtime User
i found the following thread on searching webapps keyword. It is very useful and straight forward concept.

https://www.b4x.com/android/forum/threads/webapp-example-task-manager-using-websockets-sqlite.39884/

my question is: if i want to access say 4 tables in a database using the above concept, will the below coding work or is there any other way to achieve the result ?
B4X:
    ' Init the webserver
    srvr.Initialize("srvr")
    ' Add the websockets
    ' TaskMgr Handler = TaskMgr.bas 
    srvr.AddWebSocket("/ws", "TaskMgr")
    srvr.Port = 51042

    srvr.AddWebSocket("/ws1", "tt1")  ( tt1 is one more class module for the next web client form)
    srvr.Port = 51043

    srvr.Start
    '
    StartMessageLoop
 

elitevenkat

Active Member
Licensed User
Longtime User
No. The server will only listen to the last set port.

It is important to understand that the server will load index.html by default. In this case you just need to make a copy of index.html (index2.html) and load /ws1 instead of /ws in index2.html.

You can then access it with: 127.0.0.1:51042/index2.html

Ok Erel, let me if i understood t correctly:

in server project i have to open a socket for each client page (index...html)
B4X:
srvr.AddWebSocket("/ws1", "tt1") ( tt1 is one more class module for the next web client form)
write the relevant code in the tt1 class module

in the html page i need to change the following line

    // Connect to the server and fetch the data = the handler ToDoMain.bas is called
       b4j_connect("/ws"); TO   b4j_connect("/ws1");

[code/]

did i get it ?
 
Upvote 0
Top