B4J Question Network Server - Multi Client

Status
Not open for further replies.

marco.canta

Active Member
Licensed User
Longtime User
Hi I have a few days of study and tests I could not solve. I need your help.
I need to create a local network (not the internet) between a server on Android (B4A) and multi Client on Windows (B4J).
The server must be able to send String data to all clients and receive String data from clients.
I was currently trying Erel's "MJPEG / CCTV Server" example.
Help ... Thanks

Marco
 

DonManfred

Expert
Licensed User
Longtime User
I would setup the Server with B4J on Windows.
All Clients (B4J and B4A) could connect to it to exchange data.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
But can you use MQTT without having internet connection ?
Yes, you can have a MQTT server (broker) in your local network and connect to if from the clients
 
Upvote 0

marco.canta

Active Member
Licensed User
Longtime User
I wrote this code to create an MQTT Broker ... can it work ?
The port I decide by code, the IP address depends on the hardware where the program is running.
Quite right ?

Thank you

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim broker As MqttBroker
    Dim MyLan As ServerSocket
    
    Private Label1 As Label
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Title = "Mqtt Broker"
    MainForm.Show

    Label1.Text = MyLan.GetMyIP & " : 51041"

    broker.Initialize("", 51041)             'first parameter is the event name. It is currently not used.
    broker.DebugLog = True
    broker.Start
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
 
Upvote 0

marco.canta

Active Member
Licensed User
Longtime User
A perhaps trivial question, but one that interests me a lot.
is it possible to query a database through MQTT?
... if I could have some info?

Thank you
Marco
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
is it possible to query a database through MQTT?
Not really. MQTT does not have a connection to the database.

You can for sure let the broker use a connection and query data from the db based on a message inoming.

Sounds like the wrong solution!
 
Upvote 0

marco.canta

Active Member
Licensed User
Longtime User
I would need in an Mqtt message to have several separate strings and object, is it possible to do it ?
Is it possible to have multiple Payload ?

Thanks Marco
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

marco.canta

Active Member
Licensed User
Longtime User
Thanks Erel, I solved by studying the MQTTCanvas ... and in particular the solution is here

B4X:
    Type CircleData (x As Double, y As Double, clr As Int)


I created one with my needs.
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
Does MQTTBroker and Mqttclient could work together in same no-ui project ?
 
Upvote 0
Status
Not open for further replies.
Top