Share My Creation Multiple jRDC2 sessions on one server

jrdc2screen.png

This is a small modification to the jRDC2 library, making it possible to connect multiple apps to the same server. I've used an array to store connection info so it's only limited by the capability of the server. The video I've attached only shows connections to 2 different databases but I've had 4 going at once. All but 1 of the changes are to the jrdc2 code, but there is one minor change to the DBRequestManager so it can pass the database name to the jrdc server. (which was an idea from Erel in a different post)
B4X:
Private Sub SendJob(j As HttpJob, Data() As Byte, Tag As Object, Method As String) As HttpJob
    j.Tag = Tag
    j.PostBytes(link & "?method=" & Method & "&" & "database=" & Main.dbname , Data)
    Return j
End Sub
*Note that you will need to add the variable dbname to the Main routine.

Also, you'll need to have separate config files. What I've done is renamed the individual config.properties files to [dbname].config, this makes for less changes in the code as the dbname is being passed to the server anyway.

Here is a link to the video:
http://usbyteandwire.com/jrdc2video.mp4
The window on the left is the server output (shown via VNC) and the 2 other windows are running a test program on my laptop connecting to 2 different database

I've attached the code, there really isn't that many changes but this zip file is only a skeleton, you will need to include real config files and make the change to the DBRequestManager in your apps to make the whole thing work
 

Attachments

  • jrdc2+.zip
    5.5 KB · Views: 184
Top