Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte)
Dim obj As Object = serializator.ConvertBytesToObject(Payload)
If obj Is CircleData Then
If Topic = mytopic Then Return 'the circle was already drawn
Dim cd As CircleData = obj
DrawCircleData(cd)
Else 'obj is string
Dim s As String = obj
Select s
Case "clear"
Canvas1.ClearRect(0, 0, Canvas1.Width, Canvas1.Height)
Case "close"
MainForm.Close
End Select
End If
End Sub
Sub Canvas1_MouseDragged (EventData As MouseEvent)
If mqtt.Connected = False Then Return
Dim cd As CircleData
cd.x = EventData.X
cd.y = EventData.Y
cd.clr = Rnd(0x80000000, -1)
DrawCircleData(cd)
mqtt.Publish(mytopic, serializator.ConvertObjectToBytes(cd))
End Sub
CloudMQTT support MQTT over websockets. MQTT over websockets allowes every browser to be a MQTT client. You can push messages to your browser when an event occurs or publish messages to your device. CloudMQTT Websockets Port (TLS only) can be found on the details page for your instance.
The Paho JavaScript Client is a browser-based library that can be used when connecting WebSockets to an MQTT server. Reference documentation can be found here.
, but I believe many people are interested in WebSockets as well.how to use ClouDMQTT (SSL, authentication and authorization)
Try this:
1. Download: www.b4x.com/b4j/files/MQTTCanvas.jar
2. Double click on the jar. You should see this window:
Now draw something. The drawing will show on every instance of this app (worldwide).
You can open two instances to see it.
It uses CloudMQTT. Note that the free plan which is the one used here supports up to 10 concurrent connections.
Please don't make duplicate posts.
After continuous testing, chat_b4a is available, running well in GPRS or in WiFi network, thanks, the problem has been resolved, and the next step is to analyze the code.Please don't make duplicate posts.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?