I was looking for MQTT (Mosquitto protocol implementation) using Indy components (that supports FMX [Delphi Firemonkey framework]).
I found this repo https://github.com/wizinfantry/delphi-mqtt-client — which seems to work after adding the following fix:
On file .\delphi-mqtt-client\LIB\MQTT.pas on function ‘function TMQTT.WriteData(AData: TBytes): boolean;’ using proper TMemoryStream something like that:
function TMQTT.WriteData(AData: TBytes): boolean;
var
sentData: integer;
attemptsToWrite: integer;
Stream: TMemoryStream;
nCount: Integer;
pData: TArray<byte>;
begin
// :
// ;
try
Stream := TMemoryStream.create;
nCount := Length(AData) - sentData;
pData := Copy(AData, sentData - 1, Length(AData) + 1);
Stream.Write(pData, nCount);
Stream.Seek(0,0);
FSocket.IOHandler.Write(Stream, Length(AData) - sentData);
Stream.Free;
Result := True;
FisConnected := true;
except
raise;
Result := False;
FisConnected := false;
end;
// :
// ;
end;
Although it is only Alpha version, it does seem to do the basic functionality.
Seems to me this repo is a forked version of https://github.com/jamiei/Delphi-TMQTT2 which is the VCL version using Synapse TCP components.
I ran basic tests on Win, Android and Linux (using Delphi Sydney 10.4.2 with Linux GetIt addon)… all seems to work properly — (Linux had a little free memory issue when subscribing a topic — which required try except — as a fast fix)