Delphi

Example WebSockets Server And Client Chat Application

WebSockets are gaining more and more strength with the implementation in most browsers, including for mobile devices. This article introduces briefly, the concept of WebSockets, and creates a chat app using a websockets component for Delphi, by Delphi component provider Esegece. What are Websockets? The WebSockets protocol allows the creation of a client-server communication channel with bidirectional transmission where both sides (client and server) can transmit data simultaneously. WebSockets came to fill the shortcomings of the HTTP protocol for this purpose, which by the way, is unidirectional (transmission occurs only from one end to the other). The most common uses for WebSockets are, among other things: home brokers (where quotes are updated all the time), social network feeds, chat apps, collaborative tools, and even multi-player games What are the differences between HTTP and WebSockets? WebSockets are a great choice if there is a need for a connection to remain open for a long time for constant data exchange. In summary, the benefits over HTTP are Low Latency, Persistent Connection and Full-Duplex (bidirectional transition). A WebSockets Delphi component To create our chat app we will use the WebSockets component. Here we are using the eSeGeCe Delphi WebSocket component. You can check its benefits here. Also, you can check some implementations here and the documentation here. To start the work, you need to download the eSeGeCe Delphi WebSocket Components and the Indy Components. These two and a video of how to install them, you can check here. How to create a WebSockets Delphi client for a chat application Let’s start with the client-side. After installing the components, get a TsgcWebSocketClient component along with two TEdit a TMemo, and a TButton. The two TEdit controls will be used as name and message fields. The TMemo control will be the field that displays all messages. In the TsgcWebSocketClient properties, you need to change just the host and port. Add ‘localhost’ to the host and 5416 to the port. Looking at the code, there are two main parts. The connection and the messages. For connection and disconnection, you can add the following in the OnShow and OnClose methods of the form: procedure TFrmClient.FormShow(Sender: TObject); begin sgcWsClient.Active := True; end; procedure TFrmClient.FormClose(Sender: TObject; var Action: TCloseAction); begin sgcWsClient.Active := False; end; procedure TFrmClient.FormShow(Sender: TObject); begin   sgcWsClient.Active := True; end;   procedure TFrmClient.FormClose(Sender: TObject; var Action: TCloseAction); begin   sgcWsClient.Active := False; end; To receive a message is very simple. The OnMessage event of the TsgcWebSocketClient, already comes with the text sended by the server. You just need to get it and put on the TMemo component: procedure TFrmClient.sgcWsClientMessage(Connection: TsgcWSConnection; const Text: string); begin mmLog.Lines.Add(Text); end; procedure TFrmClient.sgcWsClientMessage(Connection: TsgcWSConnection;   const Text: string); begin   mmLog.Lines.Add(Text); end; Sending a message over a WebSockets connection using Delphi To send a message is also, very simple. You can use the OnClick event of the button: sgcWsClient.WriteData(edtName.Text + ‘: ‘ + edtMessage.Text); sgcWsClient.WriteData(edtName.Text + ‘: ‘ + edtMessage.Text); Creating a WebSocket Delphi Server for a Chat Application For this WebSocket Delphi Server Example, we will need the TsgcWebSocketHTTPServer component, and at least, a TMemo. In the sgcWebSocketHTTPServer properties Options, mark the HTML files. Also in Fallback/ServerSentEvents/Retry, set to 3 and set the port to 5416. Here we also have two main parts, when looking in the code: the connection, and the messages. You […]

Read More

Developer Stories: Georgi Todorov Gerasimov Talks Us Through His Sophisticated File Encryption App

Georgi Todorov Gerasimov has been using Delphi for many years. He has a showcase entry submission (FPS-SE) at the Delphi 26th Showcase Challenge and we got to talk to him about his great Delphi experiences throughout the years. You can purchase and download his application over at File Protect System website. When did you start using RAD Studio Delphi and have long have you been using it? We have been using RAD Studio/Delphi for years. The moment Delphi XE entered the market, we started to work on a project for post quantum encryption of sensitive to critical information, which we named File Protect System – FPS. What was it like building software before you had RAD Studio/Delphi? Before the advent of RAD Studio/Delphi we faced many problems in the development of specialized REST servers. Another serious problem that our team has faced in that time was testing the end-user applications, which were utilizing web based interface. How did RAD Studio Delphi help you create your showcase application? With the advent of RAD Studio XE7/Delphi all R&D processes passed to a qualitatively new level. The technical abilities that provided us technologies like Datasnap, Tethering, Indy, FastReport, FireMonkey, etc. allowed us to speed up development processes and to raise the efficiency and reliability of our software products. At the moment we are reorganizing our working processes in order to start working with RAD Studio 10.4 Sydney. What made RAD Studio Delphi stand out from other options? One of the main advantages of RAD/Studio Delphi is the presence of unique instruments that allow quick implementation of attractive by its nature interface solutions. Another significant advantage is the high quality of the visual components and the exceptionally good compilers. What made you happiest about working with RAD Studio Delphi? It is a pleasure to work with RAD Studio/Delphi because this is an IDE that allows the developers to get a view of the project as a whole. When we get the result, every member of our team is satisfied, and that gives us the ambition to continue our development and grow. What have you been able to achieve through using RAD Studio Delphi to create your showcase application? RAD Studio XE7/Delphi helped us to finalize successfully the first versions of the File Protect System – FPS. We were able to create application that provides the end user with the ability to protect its own files and electronic messages. Something more, the application we developed allows the user to transform every single electronic device (including mobile ones) into high performance encryption system What are some future plans for your showcase application? File Protect System will continue to evolve in the future. At the moment our team is working on the integration of server-based solutions for post quantum protection of corporate structures that are using DB systems like Oracle, MS, MySQL, and DB2. Along with this we are working on our mobile solutions and DLP (Data Loss Prevention) modules that expand the functionality of File Protect System (FPS). Something more, we are continuously evolving our integrated mail client BS Mail, which is becoming popular as a stand-alone application for critical information transfer. Thank you for taking the time to talk to us Georgi. Take a look at his entry showcase below and see what kind of […]

Read More

Powerful Advanced Scientific Computing – it’s easy!

What is Scientific Computing? According to Golub and Ortega in 1992, Scientific Computing is the collection of tools, techniques, and theories required to solve mathematical models of problems in Science and Engineering. A majority of these tools, techniques, and theories are originally developed in Mathematics, which are many of them having their genesis long before the advent of electronic computers. Computation becomes crucially important in situations such as: The problem at hand cannot be solved by traditional experimental or theoretical means, such as attempting to predict climate change Experimentation may be dangerous, e.g., characterization of toxic materials The problem would be too expensive or time-consuming to try to solve by other avenues, e.g. determination of the structure of proteins Nowadays, Scientific Computing is acknowledged as the “third pillar of science”, standing right next to theoretical analysis and experiments for scientific discovery. Why use Python for Scientific Computing? Here are the 6 reasons to use Python for Scientific Computing: Python has built-in support for Scientific Computing. Python is a highly extensible language. Python has very good input/output (I/O) options. Python has strong support for task automation. Python has bridges to MATLAB or Octave. Python can use a web front end. Delphi adds Powerful GUI Features and Functionalities to Python In this tutorial, we’ll build Windows Apps with extensive Scientific Computing capabilities by integrating Python’s Scientific Computing libraries with Embarcadero’s Delphi, using Python4Delphi (P4D). P4D empowers Python users with Delphi’s award-winning VCL functionalities for Windows which enables us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python Web Scraping applications. Python4Delphi also comes with an extensive range of demos, use cases, and tutorials. We’re going to cover the following… How to use NumPy, SciPy, SymPy, scikit-learn, Theano, and Cirq Python libraries to perform Scientific Computing tasks All of them would be integrated with Python4Delphi to create Windows Apps with Scientific Computing capabilities. Prerequisites Before we begin to work, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in the Getting Started With Python4Delphi video by Jim McKeeth. Time to get Started! First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link. Open Demo01.dproj. 1. How do I enable NumPy inside Python4Delphi in Windows? NumPy is a popular Python library used for scientific computing applications. NumPy is an acronym for “Numerical Python”. NumPy is the fundamental package for array computing with Python. NumPy’s operations are divided into three main categories: Fourier Transform and Shape Manipulation, Mathematical and Logical Operations, and Linear Algebra and Random Number Generation. To make it as fast as possible, NumPy is written in C and Python. Besides its obvious scientific uses, NumPy can also be used as an efficient multi-dimensional container of generic data. Arbitrary data-types can be defined. This allows NumPy to seamlessly and speedily integrate with […]

Read More

Photomate Automation Supercharges Your Inventory Workflow

The workflow behind the selling and buying of vehicle parts is convoluted and tricky to navigate. It typically involves lots of photos of metallic objects so that the buyer – or seller – can more easily identify whether or not the part is the right one. Photomate works in conjunction with the Car-Part.com website and their Checkmate inventory management system to ease the process of taking those identifying photos and uploading them to the correct places to create online listings. The app greatly simplifies that entire workflow process. RAD Studio Delphi powers Photomate Photomate is written using RAD Studio Delphi where it uses the power of the Firemonkey FMX cross-platform framework to integrate with the mobile device’s built-in camera and sensors to perform its magic. What does the Photomate developer say about their app? According the developer, “The photos you take in Photomate are sent to the Checkmate inventory management system, and then uploaded to online listings. When you include photos in your online listings, you help your customers feel more comfortable browsing and purchasing parts from you. With Photomate, you have the opportunity to select which parts of your inventory need photos to ensure that all of your online listings have images.” Unique features listed for the app include Select specific parts in your inventory that need photos, and assign these parts to Photomate Assign specific parts to specific employees, creating individual “to do” lists Communicate between managers, employees, and coworkers with comment fields Take photos or use images already in your device’s photo gallery Select the best image to serve as the part’s thumbnail for online listings Set any image to be “private” (sent to Checkmate, but not posted online) Send images to Checkmate to be included in inventory details and uploaded to online listings on Car-Part.com, Car-Part Pro, Trading Partners, eBay, mobile searches, and individual recycler websites Google Play Photomate Screenshot Gallery

Read More

Photomate Automation Supercharges Your Inventory Worflow

The workflow behind the selling and buying of vehicle parts is convoluted and tricky to navigate. It typically involves lots of photos of metallic objects so that the buyer – or seller – can more easily identify whether or not the part is the right one. Photomate works in conjunction with the Car-Part.com website and their Checkmate inventory management system to ease the process of taking those identifying photos and uploading them to the correct places to create online listings. The app greatly simplifies that entire workflow process. RAD Studio Delphi powers Photomate Photomate is written using RAD Studio Delphi where it uses the power of the Firemonkey FMX cross-platform framework to integrate with the mobile device’s built-in camera and sensors to perform its magic. What does the Photomate developer say about their app? According the developer, “The photos you take in Photomate are sent to the Checkmate inventory management system, and then uploaded to online listings. When you include photos in your online listings, you help your customers feel more comfortable browsing and purchasing parts from you. With Photomate, you have the opportunity to select which parts of your inventory need photos to ensure that all of your online listings have images.” Unique features listed for the app include Select specific parts in your inventory that need photos, and assign these parts to Photomate Assign specific parts to specific employees, creating individual “to do” lists Communicate between managers, employees, and coworkers with comment fields Take photos or use images already in your device’s photo gallery Select the best image to serve as the part’s thumbnail for online listings Set any image to be “private” (sent to Checkmate, but not posted online) Send images to Checkmate to be included in inventory details and uploaded to online listings on Car-Part.com, Car-Part Pro, Trading Partners, eBay, mobile searches, and individual recycler websites Google Play Photomate Screenshot Gallery

Read More

This AI API Makes Your App A “Fast Style” Artistic Genius

The AI API “Fast Style” is a form of graphical style transfer which uses a neural network to combine the artistic styles of one image with another to render a new unique image. You can think if it like taking a photograph and combining it with a Manet painting to produce a unique photo after the style of Manet. To make art, we will use the help of DeepAi.org a platform that you can use to make a lot of artificial intelligence projects. One of them is “fast style transfer”. We will connect with their API using Delphi. REST and Delphi makes the API easy to use Delphi has a tool called REST Debugger that makes it easy to connect with a REST API. After using it and successfully make the connection, you can copy the components into your Delphi application. Let’s dive into the DeepAi API and see how to build a desktop application to make art. How to connect with DeepAi API? DeepAi has good documentation around their API, which you can check here. First of all, you will need to make an account on DeepAi.org and take your API key. You are gonna need it later. From the Fast Style documentation, you can see that you will need to send three parameters to the API endpoint. Two links or files with images (where one is the image to render and the other, the style you want to apply), and your API key. How do I use Delphi to Connect with DeepAi API REST endpoints ? First of all, let’s use the REST Debugger found in RAD Studio Delphi. The REST Debugger is a visual tool to connect with any API, make a call, and get a response. In your Delphi IDE,. To use it, in the IDE menu, go to Tools > REST Debugger. Change the Method to POST and insert the API Endpoint ( https://api.deepai.org/api/fast-style ) in the URL field. Then, go to the Parameters Tab. To add the image links, click on the Add button. If you want to send a link directly from a web link, on Kind, select BODY. If you want to send a file of your hard drive, select FILE instead. In the name, write ‘content’ and put the link of the image in the value. For your style image, just change the name to ‘style’. Lastly, click on add again e now, select HEADER on Kind and, on name, write api-key and on value, put your API key value. Sending a REST request to the DeepAI API Now, click on Send Request and after some time, you should receive a 200 response and, on Tabular Data Tab, you will see the output_url, with the link of the image that the artificial intelligence created: Congrats, now you can send and get data from an Artificial Intelligence API and use it as you want. How do I build a Windows desktop application to send and get images from the DeepAi API? The application we are gonna build here will get the images from your computer, show and send them to the deepAi API. Also, it will show the image that the API returns and save it into the application folder. So, with a form already created, paste the components copied from the […]

Read More

Powered by Delphi: The Ultimate App For Tinnitus Sufferers

It’s often overlooked that writing a Delphi application can make a real difference to people’s lives in a very meaningful and profound way. Tinnitus Help by US Developer Mango Chutney may just be one of those game-changing Delphi mobile apps. According to the US Center For Disease control and the American Tinnitus Association, around 15% of all Americans, around fifty MILLION people, suffer from some level of tinnitus. Those percentages are dwarfed by the numbers of people worldwide who also suffer what can be a debilitating condition. It’s a subject brought to light recently by the hit Amazon movie “The Sound Of Metal” which documents the journey into hearing loss of a rock drummer – played by actor Riz Ahmed. Your Delphi programs could make a positive difference to people’s lives Given the numbers of people who live every day with the difficulties brought about by tinnitus German developer IND (Ingenieurbüro für Nachrichten und Datentechnik) are well-placed to really touch user’s lives in a positive and possibly transformative way. ‘Tinnitus Help’ is eight programs in one. As stated by the developer, “The ultimate application for tinnitus sufferers. Only naturally produced sounds of musical instruments and sounds of Mother Nature – no synthesizers! Developed by an expert software engineer in the field of frequency analysis and a leading music psychologist, music therapist and hearing therapist with more than 20 years’ experience in the treatment of tinnitus sufferers. Used very successfully in the treatment of tinnitus.” Google Play Tinnitus Help Screenshot Gallery Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.Start Free Trial   Upgrade Today    Free Delphi Community Edition   Free C++Builder Community Edition

Read More

Working Example Code of Using STOMP In Your Application

object frmMain: TfrmMain   Left = 0   Top = 0   BorderIcons = [biSystemMenu]   BorderStyle = Single   Caption = #144’Delphi STOMP Client’   ClientHeight = 495   ClientWidth = 384   FormFactor.Width = 320   FormFactor.Height = 480   FormFactor.Devices = [Desktop]   OnCreate = FormCreate   DesignerMasterStyle = 0   object btnSubscribe: TButton     Position.X = 32.000000000000000000     Position.Y = 32.000000000000000000     TabOrder = 0     Text = ‘Subscribe’     OnClick = btnSubscribeClick   end   object edtTopic: TEdit     Touch.InteractiveGestures = [LongTap, DoubleTap]     TabOrder = 1     Position.X = 120.000000000000000000     Position.Y = 32.000000000000000000     Size.Width = 233.000000000000000000     Size.Height = 22.000000000000000000     Size.PlatformDefault = False   end   object Label1: TLabel     Position.X = 120.000000000000000000     Position.Y = 16.000000000000000000     Text = ‘Topic’     TabOrder = 2   end   object btnPublish: TButton     Position.X = 32.000000000000000000     Position.Y = 80.000000000000000000     TabOrder = 3     Text = ‘Publish’     OnClick = btnPublishClick   end   object edtMessage: TEdit     Touch.InteractiveGestures = [LongTap, DoubleTap]     TabOrder = 4     Position.X = 120.000000000000000000     Position.Y = 80.000000000000000000     Size.Width = 233.000000000000000000     Size.Height = 22.000000000000000000     Size.PlatformDefault = False   end   object Label2: TLabel     Position.X = 120.000000000000000000     Position.Y = 64.000000000000000000     Text = ‘Message’     TabOrder = 5   end   object Memo1: TMemo     Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]     DataDetectorTypes = []     Position.X = 32.000000000000000000     Position.Y = 120.000000000000000000     Size.Width = 321.000000000000000000     Size.Height = 345.000000000000000000     Size.PlatformDefault = False     TabOrder = 6     Viewport.Width = 317.000000000000000000     Viewport.Height = 341.000000000000000000   end end

Read More

Developer Stories: Aldo Victoria Talks About Uworktify

Aldo Victoria started using Delphi in 2001. His application (Uworktify: A Fun Online Print Service Provider App Is Built In Delphi) was one of the submitted showcase entries over at the Delphi 26th Showcase Challenge. Aldo took some time out of his busy schedule to give us some background about how he acquired Delphi skills and knowledge. Head over to the Uworktify website for further information on Aldo’s showcase entry app. When did you start using RAD Studio Delphi and have long have you been using it? I started using Delphi 5 back in 2001. I used Delphi as the main programming language of a telecom company that I worked for from 2001 to 2007. In 2014, I started to experiment with using Delphi for mobile development. Then, in 2019, I started the development of a mobile bond trading app, that was acquired by the second biggest bank in the Dominican Republic. Unfortunately, the bank uses IONIC as their main development language, so we are migrating the mobile bond trading app to Ionic for this customer. We will continue the development of the mobile app for Delphi and Ionic. In 2020, I funded a startup called Uworktify. Uworktify is a Tech Startup incorporated in Delaware, US. We are developing a mobile app and platform to help people aged 25-50 years and small sized businesses that want additional money and those who have underused assets by sharing the asset with the community through our high tech platform, which takes automatic management of all aspects of asset-sharing such as ordering, payment, delivery, CRM, Insurance tech, and AI to manage asset usage/promotion. What was it like building software before you had RAD Studio Delphi? I used C before Delphi. Development using C was very hard and slow! How did RAD Studio Delphi help you create your showcase application? I was able to develop the app in just a couple of months mostly completely by myself. I really think that I was able to do it this way because Delphi is a great tool. What made RAD Studio Delphi stand out from other options? I am not sure about the answer to this question. I think that they are really good free tools for developing mobile apps out there. For me, the biggest stand out is that I had good programming skills already with Delphi and I was able to re-use them to create a mobile app. What made you happiest about working with RAD Studio/Delphi? The graphical IDE and the language is very friendly. Delphi is updated all the way! I haven’t found anything that I can’t do with Delphi, no matter how complex the task is. What have you been able to achieve through using RAD Studio Delphi to create your showcase application? Developed mobile applications for Android/iOS Integrated the following platforms: AWS Amazon S3 Stripe Twillio SendGrid Use other REST API Application What are some future plans for your showcase application? We plan to move the operation from the Dominican Republic to USA and start looking for funding. In 2021, we plan to have the application available in the USA and in other countries by 2022. On the technical part, we are developing the integration of the application with Hubspot and Uber. Thank you, Aldo! Check out Aldo’s showcase entry below […]

Read More

Detecting Logos On Images Using Google Cloud Vision API

It’s a cliché that Developers are known for their taste to work long hours while drinking coffee… so, if you are into programming you most probably know the logo in the image below as it stands for the American multinational and world’s largest coffeehouse chain, Starbucks! The power of logos The point is that there is no name written in the coffee mug, just a logo. Let’s imagine for a moment that I don’t know which brand the logo represents; wouldn’t it be nice to have a way to find out what the logo stands for and to whom it belongs? Even more than that – wouldn’t it be even better if we would incorporate that ability to recognize the logos in our own Windows, desktop and mobile applications? The good news is that’s exactly what we can do with the Google Cloud Vision API. Google Cloud Vision API Logo Detection API The option for “Logo Detection” is a part of the Google Cloud Vision API that we can use to detect and extract information about multiple logos in an image. For each logo detected Google provides a textual description of the entity identified, a confidence score – how certain the machine learning AI is that the detection is accurate – and a bounding polygon for the logo in the file so we know where it is located within the area of the image. We can easily use machine-learning AI in our Delphi applications Google Cloud’s Vision API offers powerful pre-trained machine learning models that you can easily use on your desktop and mobile applications through REST or RPC API methods calls. Lets say you want your application to detect objects, locations, activities, animal species, products, or maybe you want not only to detect faces but also their emotions, or you may have the need to read printed or handwritten text, this and much more is possible to be done for free (up to first 1000 units/month per feature) or at very affordable prices and scalable to the use you make with no upfront commitments. We can use RAD Studio and Delphi to easily setup its REST client library to take advantage of Google Cloud’s Vision API to empower our desktop and mobile applications and if the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format. Our RAD Studio and Delphi applications will be able to either call the API and perform the detection on a local image file by sending the contents of the image file as a base64 encoded string in the body of the request or rather use an image file located in Google Cloud Storage or on the Web without the need to send the contents of the image file in the body of your request. How do I set up the Google Cloud Vision Logo Detection API? Make sure you refer to Google Cloud Vision API documentation in the Detect Logo section – https://cloud.google.com/vision/docs/detecting-logos – but in general terms this is what you need to do on Google’s side: Visit https://cloud.google.com/vision and login with your Gmail account Create or select a Google Cloud Platform (GCP) project Enable the Vision API for that project Enable the Billing for that project Create a API Key credential How do […]

Read More