Edit: B4AServer is now available here: http://www.b4x.com/forum/basic4andr...nt-enterprise-house-android-applications.html
This is a proof of concept of a mini-project which will soon be available.
The purpose of this project is to make it simpler to connect one or more devices to a desktop that is acting as a server.
The first version will allow the devices to download files and upload files to the server and to run shell commands on the server (returning the result to the device).
B4AServer will simplify the development of in-house applications and make it easier to integrate the mobile devices with existing applications and databases.
For example you can create a simple desktop program that accesses your local database and returns the result to the device. The device will then connect to the server, the server will run the custom program and will return the result to the device.
Or you can upload a file and the call a program that will print this file.
It may be a bit surprising but it is pretty difficult to connect to a regular desktop running Windows due to firewall issues. This makes the solution a bit complicated. I've tried to hide the complexity in the service module and I hope that the solution will be simple enough.
An example code that downloads and uploads files looks like
B4AServer is made of three components:
- "Board" server - An online site running a php script. The desktop server polls the board server every several seconds and checks if there are any waiting devices that want to connect.
- Desktop server - This is a java server.
- Android devices - When a device wants to connect (assuming that it is not already connected) it calls the board server. The desktop server will then see the waiting device(s) and connect to the device(s). Once connected the communication is done directly between the device and the desktop server. There are no firewall issues as the desktop creates an outgoing connection to the device.
Note that the online site used in this example should only be used for development. There are absolutely no guarantees regarding its availability.
I will explain how to set the board server when this project is ready. It is pretty simple and can even be done with a shared hosting server.
You can try the first draft version. Download the two attached zip files.
Choose a unique server name. It can be any string you want (letters and numbers only).
The server name is used by the board server to support multiple desktop servers.
In the desktop package, open config.properties and set the ServerName property as needed.
Run Run.bat to start the server.
In the device package (it is a B4A project) you will need to change this line to match the server name:
Also update Sub btnSendFile_Click and set the file to an existing file.
Check the Logs tab to see how it is working.
Your feedback and/or questions are more than welcomed!
This is a proof of concept of a mini-project which will soon be available.
The purpose of this project is to make it simpler to connect one or more devices to a desktop that is acting as a server.
The first version will allow the devices to download files and upload files to the server and to run shell commands on the server (returning the result to the device).
B4AServer will simplify the development of in-house applications and make it easier to integrate the mobile devices with existing applications and databases.
For example you can create a simple desktop program that accesses your local database and returns the result to the device. The device will then connect to the server, the server will run the custom program and will return the result to the device.
Or you can upload a file and the call a program that will print this file.
It may be a bit surprising but it is pretty difficult to connect to a regular desktop running Windows due to firewall issues. This makes the solution a bit complicated. I've tried to hide the complexity in the service module and I hope that the solution will be simple enough.
An example code that downloads and uploads files looks like
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
'Change test1 to the server name you choose!
B4AServer.Initialize("http://66.84.14.57/android/b4a_server.php", "test1", "Main")
End If
btnSendFile.Initialize("btnSendFile")
btnSendFile.Text = "Send File"
btnReceiveFile.Initialize("btnReceiveFile")
btnReceiveFile.Text = "Receive File"
Activity.AddView(btnSendFile, 10dip, 10dip, 300dip, 100dip)
Activity.AddView(btnReceiveFile, 10dip, 150dip, 300dip, 100dip)
End Sub
Sub TaskComplete(Result As TaskResult)
Log(Result.Id & " done. Success=" & Result.Success & ", msg=" & Result.Message)
If Result.Id = imgTask AND Result.Success = True Then
Activity.SetBackgroundImage( _
LoadBitmapSample(B4AServer.DownloadFilesFolder, Result.Id, Activity.Width, Activity.Height))
End If
End Sub
Sub btnSendFile_Click
B4AServer.SendFile(File.DirRootExternal, "somefile.dat")
End Sub
Sub btnReceiveFile_Click
imgTask = B4AServer.ReceiveFile("logo.jpg")
End Sub
- "Board" server - An online site running a php script. The desktop server polls the board server every several seconds and checks if there are any waiting devices that want to connect.
- Desktop server - This is a java server.
- Android devices - When a device wants to connect (assuming that it is not already connected) it calls the board server. The desktop server will then see the waiting device(s) and connect to the device(s). Once connected the communication is done directly between the device and the desktop server. There are no firewall issues as the desktop creates an outgoing connection to the device.
Note that the online site used in this example should only be used for development. There are absolutely no guarantees regarding its availability.
I will explain how to set the board server when this project is ready. It is pretty simple and can even be done with a shared hosting server.
You can try the first draft version. Download the two attached zip files.
Choose a unique server name. It can be any string you want (letters and numbers only).
The server name is used by the board server to support multiple desktop servers.
In the desktop package, open config.properties and set the ServerName property as needed.
Run Run.bat to start the server.
In the device package (it is a B4A project) you will need to change this line to match the server name:
B4X:
If FirstTime Then
'Change test1 to the server name you choose!
B4AServer.Initialize("http://66.84.14.57/android/b4a_server.php", "test1", "Main")
End If
Check the Logs tab to see how it is working.
Your feedback and/or questions are more than welcomed!