B4A Library MQTT Multiplayer Library

paris7162

Member
Licensed User
This is a MQTT Multiplayer Library created by one of the best B4A library creators and member in the B4X Community. I use his libraries in all of my games. I didn’t write any of this code and I told him I would keep his identity private unless he wanted to reveal who he is.

I use it to play a Multiplayer card game with an Android and iOS device. I couldn’t find a better way for and Android player to play and iPhone player. I uploaded the Broker.jar to my Linux Virtual Private Server. I send a list from B4a and a NSMutableArray (NSArray) from Xcode in Objective C.

I used the following pods to install the library on my iOS devices.
pod 'MQTTClient/MinL'
pod 'MQTTClient/ManagerL'
pod 'MQTTClient/WebsocketL'


Here is the explanation on how to use the library.

Step by step to try the demos:
- download the archive and copy the content of Lib to the directory of additional libraries of B4J;
- set a valid port number in Broker/Broker. b4j (line 10);
- open this port on your server, if necessary;
- compile the Broker.b4j project;
- upload the result (Broker.jar) on your server and execute it;
- in the two projects under Demo_Clients, enter the IP address of the server and the port used by the broker (B4A: lines 28 and 29; B4J: lines 19 and 20);
- in the Client.b4a project, you can change the method of identification of the device line 48 (the goal is that the device is identified with an unique ID; the demo code will work but that won’t be the case in a real application with many users because some devices share the same android_id);
- in the Client.b4j project, you can also change the ClientID and put whatever you want;
- run the clients and click on the Connect button.

I've used this for 2 years and it works perfectly so far. Feel free to use this however you like. B4J has been updated a few times since then so I hope this still compiles. I'm the worst programmer so I can't be of much help to anyone but I will answer what I can.
 

Attachments

Sia Kong Lam

Member
Licensed User
Hi @paris7162,

Thanks for sharing.
While compiling Broker.b4j the following error msg displayed, Cannot find 'moquette8.jar'. Where to download this jar? and any help will be much appreciated.
1588709631804.png

Regards,
Sia
 

Informatix

Expert
Licensed User

Sia Kong Lam

Member
Licensed User
Thanks for the help ilan & Domanfred. I did try all the moquette-broker from the link as suggested (tq).
When compiled, the following log displays....

main._process_globals (java line: 288)
java.lang.NoClassDefFoundError: io/moquette/server/config/IConfig
at b4j.example.main._process_globals(main.java:288)
at b4j.example.main.initializeProcessGlobals(main.java:279)
at b4j.example.main.main(main.java:27)
Caused by: java.lang.ClassNotFoundException: io.moquette.server.config.IConfig
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more

downloaded files changed from moquette-broker-0.??.jar to moquette-broker.jar

in jMQTTBrokerExtended.xml

changed from
<dependency>
<version>1</version>
<artifactId>moquette8</artifactId>
</dependency>

to
<dependency>
<version>1</version>
<artifactId>moquette-broker</artifactId>
</dependency>

Source b4j using broker.b4j without any changes.

Regards,
Sia
 

ilan

Expert
Licensed User
These jar files cannot work. Many classes are missing inside. The simplest solution is that Paris makes the file available on a Google Drive or Dropbox account because its size (3 MB) prevents it from being uploaded to the forum.
can you explain a little about the library (maybe in a new thread)? is it also for sale from your side? do you have example to see how it works? will it allow a full multiplayer option also when using libgdx and very fast games? (i have 0 experience with multiplayer but this topic always interested me and i really would like to build a real time multiplayer game)

thank you, ilan
 

Informatix

Expert
Licensed User
can you explain a little about the library (maybe in a new thread)? is it also for sale from your side? do you have example to see how it works? will it allow a full multiplayer option also when using libgdx and very fast games? (i have 0 experience with multiplayer but this topic always interested me and i really would like to build a real time multiplayer game)

thank you, ilan
This library was not made for fast & furious games. It is free since Paris posted it here.
 

paris7162

Member
Licensed User
This is a MQTT Multiplayer Library created by one of the best B4A library creators and member in the B4X Community. I use his libraries in all of my games. I didn’t write any of this code and I told him I would keep his identity private unless he wanted to reveal who he is.

I use it to play a Multiplayer card game with an Android and iOS device. I couldn’t find a better way for and Android player to play and iPhone player. I uploaded the Broker.jar to my Linux Virtual Private Server. I send a list from B4a and a NSMutableArray (NSArray) from Xcode in Objective C.

I used the following pods to install the library on my iOS devices.
pod 'MQTTClient/MinL'
pod 'MQTTClient/ManagerL'
pod 'MQTTClient/WebsocketL'


Here is the explanation on how to use the library.

Step by step to try the demos:
- download the archive and copy the content of Lib to the directory of additional libraries of B4J;
- set a valid port number in Broker/Broker. b4j (line 10);
- open this port on your server, if necessary;
- compile the Broker.b4j project;
- upload the result (Broker.jar) on your server and execute it;
- in the two projects under Demo_Clients, enter the IP address of the server and the port used by the broker (B4A: lines 28 and 29; B4J: lines 19 and 20);
- in the Client.b4a project, you can change the method of identification of the device line 48 (the goal is that the device is identified with an unique ID; the demo code will work but that won’t be the case in a real application with many users because some devices share the same android_id);
- in the Client.b4j project, you can also change the ClientID and put whatever you want;
- run the clients and click on the Connect button.

I've used this for 2 years and it works perfectly so far. Feel free to use this however you like. B4J has been updated a few times since then so I hope this still compiles. I'm the worst programmer so I can't be of much help to anyone but I will answer what I can.

Here is the link to the moquette8.jar file.

 
Top