Creating A Chat Application In Diffusion 6.0 — Push Technology

Diffusion enables the creation of scalable real-time solutions on mobile, browser or desktop. Our latest release, Diffusion 6.0, includes new features to simplify development of collaborative applications, like real-time text chat.

In this article, we’ll discuss a simple example chat application we developed to demonstrate three new Diffusion 6.0 features:

  • Time series topics
  • Topic persistence
  • Topic notifications

Time series topics

New values can be appended to the time series topic by multiple clients. They will be streamed to all subscribers of the topic in the same manner as with other topic types. Time series topics also retain a record of previous values which can be queried or updated and therefore used to create real time interactive applications which maintain a history of events.

The time series topic is a natural fit for many applications like chat or turn-based browser games, but also for creating applications which require retention of previous data points. These data points could originate from a topic that publishes prices or tracking data which can be collected and used for the purposes of data analysis or visualization.

Topic persistence

Topic notifications

Example — Embedding live chat into a website

In our example support chat application, a popup window has been embedded into a web page (we used the first World Wide Web page ever hosted at CERN) using HTML5 elements.

After the page loads, the Diffusion JavaScript client connects to the Diffusion server and creates a unique time series topic for each chat session, using a topic specification. The specification determines how many events the topic retains and how many events a new subscriber receivers.

View the code on Gist.

Here’s the code used to send a new chat message from the chat popup to the server:

View the code on Gist.

Here’s the code used to make the chat popup receive and display new messages. The client registers a callback which appends all incoming messages to an HTML element with the id ‘chatmessages.’

View the code on Gist.

To allow ‘agents’ to answer chats, we made a simple single page web application. The agent application uses topic notifications to subscribe to new chat sessions automatically.

The agent receives each user’s message history and can reply to their chats. With persistence enabled, the conversations are maintained even if the Diffusion server is restarted.

We use topic notifications to detect when a new chat session starts and update the agent view. When a new topic is added under the path /chat/chatsessions/, the addUser callback is called to add a representation of the
chat session to the agent interface.

View the code on Gist.

The time series topic can be applied creatively to implement other similar web, desktop or mobile applications. It is supported by the Javascript, Java, Android or Apple clients, and is only one of the many new features available in Diffusion 6.0.

The Diffusion® Intelligent Event-Data Platform makes it easy to consume, enrich and deliver event-data in real-time across all network conditions. Push Technology pioneered and is the sole provider of real-time delta data streaming™ technology that powers mission-critical business applications worldwide. Leading brands use Push Technology to bring innovative products to market faster by reducing the software development efforts using the low-code features. The Diffusion® Intelligent Event-Data Platform is available on-premise, in-the-cloud, or in a hybrid configuration. Learn how Push Technology can reduce infrastructure costs, and increase speed, efficiency, and reliability, of your web, mobile, and IoT application.

Learn More: View Blog Posts and Developer Resources

Originally published at on December 4, 2017.

Chief Product Officer at PUSH Technology. I have had diverse leadership roles at startups & Fortune 500s and excel at leading product organizations.