Cross platform messaging made easy with TMS MQTT

Last week we released a new product, TMS MQTT. MQTT is a standard lightweight machine 2 machine messaging protocol. This enables the instant exchange of binary or text messages between code running on various operating systems. To fully take advantage of this, we developed our TMS MQTT client to work in VCL Windows applications, FMX Windows, macOS, iOS and Android applications and also on Linux desktop or Linux variants such as Raspbian on Raspberry Pi via FPC/Lazarus.

On this 22th birthday of Delphi, I wanted to show you how our TMS MQTT component allows you to develop a messaging application in a real RAD way. I’ll do this by implementing a chat application that allows you to chat between clients running on desktops or mobile devices. This effectively takes less than 40 lines of code using the TMS MQTT component of which 15 lines already go to inserting the chat text left and right in items of an FMX listbox and another +/- 10 lines detecting the origin of the chat text that is received to decide whether to show it left or right in the listbox. So, I’d say only about 15 lines of code effectively concern using the MQTT client to do the messaging.

For this demo, we use the Mosquitto MQTT test broker and connect to it with 2 lines of code:

  TMSMQTTClient1.BrokerHostName := '';

Upon connecting, we subscribe to the topic /tms/chat/ that is the topic that will be used to exchange chat text between multiple clients. This takes 2 lines of code from the TMQTTClient.OnConnectedStatusChanged() event:

procedure TForm1.TMSMQTTClient1ConnectedStatusChanged(ASender: TObject;
  const AConnected: Boolean);
  if AConnected then

To send a message, text entered in a memo control is published on this topic with one line of code:

  TMSMQTTClient1.Publish('/tms/chat/', TMSMQTTClient1.ClientID+'!'+ memo1.Lines.Text);

Here we add the unique ID of the app sending the chat text and the chat text itself.
Finally, incoming chat text on the subscribed topic is received via the TMQTTClient.OnPublishReceived() event. The unique client ID is retrieved to decide whether to put the chat text left or right of the message listbox and this is done via the code:

procedure TForm1.TMSMQTTClient1PublishReceived(ASender: TObject;
  APacketID: Word; ATopic: string; APayload: TArray);
  msg,orig: string;
  vp: integer;
  alright: boolean;
  msg := TEncoding.UTF8.GetString(APayload);

  vp := pos('!', msg);

  if vp > 0 then
    orig := copy(msg,1,vp-1);
    alright := orig  TMSMQTTClient1.ClientID;

    msg := copy(msg, vp + 1, Length(msg));
    AddMessage(msg, alright);

And then comes the method to allows us to insert either left or right aligned text as items in an FMX listbox:

procedure TForm1.AddMessage(AMessage: string; AlignRight: boolean);
  li: Tlistboxitem;
  li := Tlistboxitem.Create(self);
  li.StyledSettings := li.StyledSettings - [TStyledSetting.ssOther];
  li.Text := AMessage;
  li.Height := 22;
    li.VertTextAlign := TTextAlign.taTrailing;

  if AlignRight then
    li.TextAlign := TTextAlign.taTrailing
    li.TextAlign := TTextAlign.taLeading;


Compile and run this application on your operating system of choice. In my case, I did setup a small chat between the client compiled for Windows and the client deployed on an iPhone:

You can download the full source code of this FireMonkey application here.

I invite you to explore the numerous exciting capabilities of machine 2 machine messaging. Note that there
are JS libs that facilitate to do MQTT messaging via websockets from a webbrowser. The demo included in the TMS MQTT download is based on messaging between a desktop or mobile client app and a web page application. With the TMS MQTT client, you can also use machine 2 machine messaging from your Raspberry Pi and send this way various sensor data captured by the Raspberry Pi to desktop or mobile apps. In a follow-up blog, we’ll explain and offer such sample project.

I look forward to hear about how you will use MQTT machine 2 machine messaging in your apps or IoT projects!

Read More

Read More

Date format converter from Text or Unix/Mac/Filetime/Microsoft to virtually any readable form

Brilliant Date format converter from dates in Text (almost any format) or timestamp numbers in Unix, Mac, Filetime or Microsoft (which is the same as Delphi TDateTime) format to any of these formats: Text Date: Date in human-readable text Wednesday, March 23, 2016 4:05:39pm RFC 822: RFC 822 formatted date Wed, 23 Mar 2016 16:05:39 +0000 ISO […] … Read More

Read More

OmniThreadLibrary 3.07 beta + plans for OmniThreadLibrary 4.0

It is almost time for a new release! If you’d like to see what 3.07 will contain – or if you just want to test it before it is out – click here. [If you are a serious OTL user - and especially if you are using pre-Seattle Delphi - please test your program(s) with the beta release. Thanks!] I have started work on OTL 4.0 which will (fingers crossed) fully support cross-platorm work. Yup, it will work on all platforms that Delphi can compile for! Multiplatform support was implemented by Sean B. Durkin so if OTL/Mobile is something you were waiting for a long time, go to OmniThreadLibrary-For-Mobile Google+ community and express your gratitude. Read more »--- Published under the Creative Commons Attribution 3.0 license
Read More

Cool Apps & Niagara Falls

Nick and Jim discuss cool mobile apps built with FireMonkey. SoundJuke turns your smartphone into your personal jukebox at any public site. It uses a combination of these Embarcadero tools in building the app: Delphi for iOS and Android, Cloud API, Parallel Programming API, REST Client Library. If your customer likes what they hear, they’ll spend more time in your store.  EarMaster turns your iPad into a private music training classroom. Powered by FireMonkey and TMS iCL plus it also uses SQLite, SSL, In-App purchases, XML and Indy components in the app. The IDE extensions CnPack and MMX were also very valuable. This video provides an excellent introduction. EarMaster is the Most Advanced App for Music Theory and Ear Training on iOS. Pocketslip will eliminate those pesky paper receipts once and for all. Pocketslip it is powered by Delphi for iOS and Android, Cloud API, Parallel Programming API, REST Client Library and FireDAC. Fast and secure point-of-sale, integrated digital receipts for you and your customers. These videos will provide insight into Pocketslip. Switchboard turns your iPhone into, well, a fully featured and networked phone system in the palm of your hand. It is for the iPhone only and uses Delphi for iOS, Cloud API, Parallel Programming API, and REST Client Library. This video will provide some details. Alpemix is a remote desktop for increasing your productivity wherever you might happen to be in the world. It is a multi-platform system compatible with iOS, Windows Mac OS X and Android so you can be productive under all circumstances and is built on the Delphi platform. More detail is available here. ValidIN is a mobile medical app that networks Croatian biomedical laboratories so that blood samples can be validated quickly and accurately. It is built on the Delphi platform for iOS and Android using FireDAC and DataSnap as well. MindGlow is a powerful meditation tool you can use to induce your mind into states of peace in those times when stress might just be a bit too much. It uses Embarcadero Delphi and FireMonkey but also Apple’s Core Audio and Google’s Android AudioTrack. More and more, the research is showing that meditation has physical health benefits.  From reduced cortisol, to increase in HRV, meditation can and will improve your health.  To gain the most of these physical benefits, Delta sessions is critical.  Serious trainers and elite athletes know that recovery and rest is an essential component to pushing past physical limits and improving overall health. Delta meditation does this in spades!  MindGlow is a fascinating app. Learn more here.
Read More

RAD Studio and Natively Compiled Code

In today's development landscape, natively compiled code is making a significant comeback, even if in a fairly different variety of scenarios. RAD Studio has always been focused on it and developers using Delphi and C++Builder probably experience its advantages without even noticing them. Natively Compiled Code: A Comeback? Let me clarify the terms first. I refer to natively compiled code as code that is compiled (at some time of the process) into machine code the target CPU can execute. As you start your application, there i no further conversion to take place. I mean, like the output of a traditional compiler producing a binary executable, but not only. For several years most of the focus has been on execution environments (.NET, Java, the various JavaScript engines) that would either interpret and execute the source code or most often an intermediate optimized format (ByteCode, IL, etc). Most of these systems benefit from some JIT (just-in-time) compiler so that each method is executed and compiled only once after loading the application. Now while this model is still extremely popular (and it is going to remain mainstream, I'm not suggesting the opposite), there are many signs of a significant comeback of natively compiled code: Apple platforms and iOS in particular have been pushing the "native only" mantra, basically disallowing execution environments other than JavaScript. Odd drawback is pushing developers to package two versions of their applications (32-bit and 64-bit) into a IPA package. Their alternative model is allowing for compilation of bitcode into binary on their own backend systems -- so you are submitting BitCode and Apple converts it to binary before the users download the app. Android has started implementing an "installation-time" compilation (ART), compiling Java ByteCode to binary when the application is downloaded. This "compilation" happens on the user devices, depending on the device CPU and OS version. Beside making it very time consuming to do a system update (as all apps needs to be recompiled), this is making Java apps execution faster. Also on Android it might come to a surprise but most of the best-selling apps are not written mostly in Java, but in C++ using the NDK. Which is the same model Delphi and C++Builder use. If you don't believe me, read for example Microsoft as they said (one year ago): "Platform defining, cross-platform, new trendy applications such as Facebook Moments, Dropbox, Office, Skype, popular games (e.g. Fruit Ninja, Clash of Clans, EA Sports titles) are all written in cross-platform C++.  Talking more numbers if you take a look at the top 50 android applications a vast chunk of them (~75%) of them leverage C++." On the Windows platform, most applications have always been native, despite Microsoft pushing .NET for a long time even Office and their mainstream applications are natively compiled and likely mostly written in Visual C++, even if there are exceptions in which Delphi is used ;-). But the trend to opening more native apps has become even more significant after Microsoft opened the Windows Desktop Bridge, with many companies previously trying to build native WinRT apps and now back the business as usual to support Windows 10 with traditional applications -- although to be honest some of them are actually .NET-based. A good example is Telegram, written in C++, which seems to have scrapped UWP WinRT plans in favor of a Desktop Bridge approach. We are witnessing a large number of Delphi (and C++Builder) applications landing to the Windows Store via the bridge. Web services space is also seeing significant migration from scripting (PHP, Ruby) to more efficient solutions in terms of processing. The original idea of "let's throw more hardware at it" doesn't always scale as expected. If you need to 2x machines (like 4 machines instead of 2) no big deal. But when you need 10x machines and the system is huge, 100 servers instead of 10 might push you to rethink the strategy. Including the fact that these servers can be power-hungry and power-consumption has become a significant decision factor. Although limited, some migration to natively compiled server side code has been happening -- or at least, migration from less efficient scripting solutions to more efficient execution environment solutions. By Why Natively Compiled? There are many reasons for this push towards natively compiled apps, at very different levels. There are also many reasons this is considered far from ideal, and (as you've seen in the list above) it happens different levels, not always in the development phase and with classic development tools. Anyway, some of the reasons include: performance, better optimization of compiled code, often combined with non-GC memory management (but not always) -- even if JITers create very fast code, they take a hit often at application start time, giving a bad first impression. In case of true scripting, compiled code also implies syntax checking it and writing more robust applications, but also here technologies vary (for example TypeScript does improve the robustness of JavaScript, even if it remains interpreted). Truly the optimization fo teh JITer for a specific machine can end up being even better than a general purpose more CPU-agnostic compiler. So I know this can be debated at length. improved security due to the fact there isn't an execution environment that might be exploited, and again because the code is binary. A related issue is better IP protection, given reverse engineering is significantly more complex on natively compiled code (even if there are notable obfuscation solutions, they often fall a bit short and they don't apply to all languages alike -- JavaScript being fairly weak on this respect) a reason for compiling code upfront (compared to BitCode or Android installation JIT) is full control on the application: if the code being executed by your customers is different from what you wrote, even testing it becomes fairly less deterministic more on the business side, the fact your company might already have existing natively compiled code that you can even move to new platforms without doing a full rewrite (for Windows 10 Store, but even in the mobile space) ca be a significant advantage single source can be native, despite claims (in the mobile space, mostly) that native code ends up being written with different languages, IDEs, and tool chains, there are technologies that allow a good balance of natively compiled code, native platforms support, and code reuse. Visual C++ is one of those (despite the fact that it has no cross-platform framework) and Microsoft is using it for their mobile apps -- and not Xamarin, it seems, while Qt and RAD Studio (on the C++ or Delphi side) offer also higher-end cross platform libraries, covering platform features and also UIs. Conclusion While I know things are way more complex than I've tried to depict in this blog post -- and sorry if I skipped or missed some relevant details -- my point was to underline the fact that "execution environment" are not the only model you should consider, they are not they way to the future, but the present is and the future will continue to be a mix of natively compiled and intermediate compilation or scripting. While a few years back things were more one sided, there are now even more signals that natively compiled code has a place and it is going to stay and receive continuous investment, both by the platforms vendors (Apple, Google) in terms of post-development tuning and by development tools vendors focused on the natively compiled space. This is a reason Delphi and C++Builder have and will keep having their role, bringing natively compiled applications to Windows 10 (Store included), the mobile space, and soon also the Linux platform -- as we saw optimizing server side code execution is also relevant. Having different options and solutions for different projects remains critical for developers. Don't rule out natively compiled code, if you thing it is just going away, you might want to reconsider. And if you have been staying on the natively compiled side, keep appreciating its value and virtues. Alternative options do have merit, for sure, but natively compiled code has a place. And not a small one!
Read More

One of our many commitments for 2017: more product demonstration videos

We already provide help and documentation in several ways: PDF developer guides for most complex components, a page with component specific tips and FAQ, a monthly knowledge base alert, ? . our TMS Support Forum with almost 10.000 forum members also offers a big help to many users. And of course our first-class support directly from our developers here at the office.

But we listened to your feedback and it was clear that many of you also wanted in addition to this videos explaining the products and offering step by step demos. So, we made it an action point and commitment for 2017 to significantly increase our offerings in videos.

With our video’s we would like to show you step by step what great features our components are offering without the need to install trial versions or spend a lot of time reading through all our documentation. No hassle, just 1 click on the video and you can see our components in action, be it in VCL applications, cross-platform FMX applications, Cloud, Intraweb, …

To show our commitment, here are already the first 3 videos we created this year in January and more will be following shortly:

Video 1 about how you can effortlessly generate pdf files from a VCL DB grid.

Video 2 about how you can use the mycloudData service which is a cloud service for structured cloud storage for data.

Video 3 about responsive design in VCL applications with the TDBAdvResponsiveList.

So we kindly invite you to get subscribed to our YouTube channel

and of course we wish you much fun in exploring our components and their possibilities!

More videos are coming in the near future.

Read More

Read More

Delphi: rbTC1416 package cannot find the Graphics unit: ensure your DCC_Namespace is correctly

I had to add this to my DCC_Namespace in the rbTC1416.dproj file to make it build under Delphi XE8: Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell; The occurrence of this DCC_Namespace setting corresponds to the “Unit scope names” of the “All configurations – All Platforms” target in the project options. That got rid of this error mesage: [dcc32 Fatal Error] ppChrt.pas(17): F2613 Unit […] … Read More

Read More


With the release of the TMS FNC UI Pack we have introduced a TMS FNC Core separation. This means the TMS FNC Core needs to be installed as a prerequisite in order to successfully install the TMS FNC UI Pack. Apart from this separation, the new core setup will not introduce breaking changes in your application, as the file names for both the TMS FNC Core and TMS FNC UI Pack have remained the same. The separation gives us the benefit of writing components that all rely on a single core, instead of duplicating units that offer exactly the same features in multiple component sets. All current and future TMS FNC products will build upon this common core. Custom Component Development for FNC Now the TMS FNC Core is released, you'll have a series of units available that can be used to write custom components yourself for our FNC framework. [FMX.][VCL.][LCL]TMSFNCBitmapContainer.pas [FMX.][VCL.][LCL]TMSFNCCustomComponent.pas [FMX.][VCL.][LCL]TMSFNCCustomControl.pas [FMX.][VCL.][LCL]TMSFNCCustomScrollControl.pas [FMX.][VCL.][LCL]TMSFNCGraphics.pas [FMX.][VCL.][LCL]TMSFNCGraphicsTypes.pas [FMX.][VCL.][LCL]TMSFNCHTMLEngine.pas [FMX.][VCL.][LCL]TMSFNCStyles.pas [FMX.][VCL.][LCL]TMSFNCTypes.pas [FMX.][VCL.][LCL]TMSFNCURLBitmapContainer.pas [FMX.][VCL.][LCL]TMSFNCUtils.pas Note that with this set of units, you are able to write a custom component from scratch. A tutorial on writing a custom component can be found in this blog post:
Read More

It is time to Modernize!

Over the last months I met hundreds of customers. It is somewhat humbling to learn about the many powerful applications built with D6, D7, Delphi 2005/2006/2007, XE2/3 and newer RAD Studio versions. Especially astounding is the number of great applications that are still maintained and evolved with D7 or 2007 technology. One of the great things about these is that they keep working and working, so why modernize and invest now? Tech is changing faster than ever before, so unless your app looks and feels modern, unless your app architecture is flexible – it can be obsolete faster than you think. Also, Windows 10 is changing a lot of things - eventually some of these old versions may not run so well and we recently informed selected customers that may be impacted. Of course, we all benefit from your modernization! We can invest more and you have even better applications... You may be surprised how much of the new trends, such as micro-services, REST APIs, Cloud Hosting are supported with RAD Studio 10.1.2. Our new Webinar series and exciting education initiatives will keep us not only on par with the competition, but leapfrog them in many areas. Our support for IoT, for example, is pretty cool. I push the Product Team by constantly asking what is new and interesting that gets customers excited, and they gave me a nice bullet list that I thought to share… Windows 10 is a BIG Deal! Microsoft is reinventing itself and Windows 10 adoption is the highest ever (400M devices as of September). We support all the latest features of Windows operating systems (from complete Unicode support to newer capabilities, such as push notifications). UX is more critical than ever before and Windows 10 brings amazing modern look and feel; you get better performing native apps with 64-bit support; 10.1.2 enables Windows App Store Deployment even before Visual Studio! Not only will your apps be better looking and have more options with the latest VCL, but they will be much more stable and “future-proofed”. You need to be mobile! Many consider mobile as a nice to have, but there are few better ways to demonstrate the value of your tool than to create a nice looking mobile app (and do it fast). FMX is production ready with lots of improvements in the latest versions and continues to evolve as the best native framework available. You can be a winner and you can start small with app tethering or build an awesome full scale app. You should just check-out some of our recent Cool Apps for great examples. You can improve app connectivity to the latest major databases with the powerful new FireDAC data access framework. This increases your flexibility making easier future infrastructure or vendors changes. You can use your code to enable new web clients and capabilities by updating your application architecture with DataSnap and RAD Server.  Don’t get left behind with other teams speaking about N-Tier architectures - you can have modern middle-tier application servers or REST-based microservices with RAD Studio today. You can also build modern REST-based thin Windows clients using the new REST VCL Client support. You will also greatly enhance your development productivity with huge increases in IDE functionality.  Whether it is through code editor enhancements or improvements to the form designer, you can develop faster than ever with the latest RAD Studio IDE. You get the power of the latest Delphi language features such as anonymous methods, parameterized types (generics), and more. They are more powerful and more useful than you expect! C++ leverages the latest C++ libraries and language features while taking advantage of the power of RAD through the VCL -- an unprecedented combination. There is no other framework for GUI development that is more efficient – we compare very well against Qt and FMX makes cross-platform development with C++ much easier. If you care about IoT (and you should) RAD Studio allows you to build applications that work with all the latest gadgets, devices, and sensors. We hold IoT awards for most innovative products! LINUX support, planned for 10.2 will get you further savings and another platform! And YES, new migration tools get you to the future faster. We can sell Delphi and even C++ Builder better. We tend to be too shy about what we bring to the table. The analysts have not been especially kind, as they look for the next new thing. I think that what we bring is incredibly relevant to the market. Fast and efficient development does not get old and we do it better than anyone else. Our team put together a really nice summary of Embarcadero for developers, "We Are Embarcadero" that I encourage you to download and share!
Read More