Dec 21, 2015 Replies: 60 It's time to learn how to use MQTT: https://www.b4x.com/android/forum/threads/59471/#content It is simple and powerful. In most cases MQTT is the best solution for low level networks. Low level network means a network solution that is traditionally based on ServerSocket + Socket + AsyncStreams. In this example we implement a chat room with one or more users. The MQTT broker is embedded in the Android app (jMqttBroker library). The clients are Android, iOS or desktop apps. Any number of users can join. When you start the Android app you can choose whether it will be the server. The other clients will connect to the server. The messages are serialized with B4XSerializator (RandomAccessFile library). B4XSerializator is very useful for cross platform communication. Users can join and leave the chat room. The list of users will be updated automatically. Note the usage of the LastWill feature. When a client is disconnected unexpectedly (and only if it is unexpectedly) the LastWill message will be sent. This allows us to remove the client from the list. The UI state is managed by StateManager (in B4A and B4i). It is a simple and flexible UI implemented with anchors. Note that it properly handles the soft keyboard changes. jMQTT library: https://www.b4x.com/android/forum/threads/59472/#content jMqttBroker: https://www.b4x.com/android/forum/threads/mqttbroker.61548 Extension to this example with auto discovery: https://www.b4x.com/android/forum/posts/480542/ Attachments Chat_B4i.zip Chat_B4i.zip 6.1 KB · Views: 2,848 Chat_B4J.zip Chat_B4J.zip 3.8 KB · Views: 4,327 Chat_B4A.zip Chat_B4A.zip 11.3 KB · Views: 3,663 Last edited: Nov 18, 2019 Click to expand...
It's time to learn how to use MQTT: https://www.b4x.com/android/forum/threads/59471/#content It is simple and powerful. In most cases MQTT is the best solution for low level networks. Low level network means a network solution that is traditionally based on ServerSocket + Socket + AsyncStreams. In this example we implement a chat room with one or more users. The MQTT broker is embedded in the Android app (jMqttBroker library). The clients are Android, iOS or desktop apps. Any number of users can join. When you start the Android app you can choose whether it will be the server. The other clients will connect to the server. The messages are serialized with B4XSerializator (RandomAccessFile library). B4XSerializator is very useful for cross platform communication. Users can join and leave the chat room. The list of users will be updated automatically. Note the usage of the LastWill feature. When a client is disconnected unexpectedly (and only if it is unexpectedly) the LastWill message will be sent. This allows us to remove the client from the list. The UI state is managed by StateManager (in B4A and B4i). It is a simple and flexible UI implemented with anchors. Note that it properly handles the soft keyboard changes. jMQTT library: https://www.b4x.com/android/forum/threads/59472/#content jMqttBroker: https://www.b4x.com/android/forum/threads/mqttbroker.61548 Extension to this example with auto discovery: https://www.b4x.com/android/forum/posts/480542/
Erel B4X founder Staff member Licensed User Longtime User Mar 24, 2023 #61 1. Thread locked. Please start a new thread. 2. See my previous post. You didn't answer my question.