Social networking has been one of the biggest game changers in the world of technology. The practice of expanding the number of one’s business and/or social contacts by connecting through individuals or groups helps in various ways. The real-time transmission of messages proved to be an interesting concept when it was introduced. Gradually, it gained popularity and prominence as and when people started accepting the essential nature of social networking.
Implementing new features in a mobile/web app is an exciting task which is demanding as well. Developers are always, eager to work and deliver under challenging scenarios. This certainly, helps the developers to improve their technical skills.
The Real-life ImplementationThis article captures the experience of building chat solution for a client, a leading telecommunication services provider. The requirement was to create a chat system within the cross-platform application and integrate with Oracle Siebel that will enable users to communicate within an organization.
The developers were required to work as a team towards the challenging task of finding the perfect solution. It was a challenging task for the developers to find the best solution. The research was narrowed down to:
- io – A real-time engine which enables bidirectional communication through a channel.
- PubNub – A library that supports real-time services with the support of multiple network protocols.
PubNub turned out to be promising in this case due to the time constraints and moreover, it has good, concise and clear documentation which is simple and straight.
Let’s get into the technical aspects of PubNub and understand the reasons behind using it.
Integration of PubNub Libraries with the Application
All the PubNub libraries were referenced to the Angular application. The referencing was completed in a short span of time but that was about just referencing the libraries, the remaining task of heavy lifting was still remaining.
Registering the Application to PubNub
- You need to visit Official PubNub website and register using a valid e-mail id.
- Login to the account which will navigate you to the developer console.
- Create an application by clicking on “create new app”.
- A new PubNub application is registered. You receive the Publish Key, Subscribe Key and Secret Key. This will be used in the code.
- Application add-ons are self-explanatory. Therefore, you can experiment with these configurations.
The registration is completed here. Now, it’s all about how you handle chat channels.
Managing Chat Channels
Managing chat channels might sound like a difficult and arduous task but actually, it can be simplified. Let’s take a simple example. You are an employee of an organization, ‘ABC’.
So, currently you are registered as an Employee of the organization, ‘ABC’. Likewise, there will be hundreds of other employees registered with ABC like Emp 1, Emp 2, Emp 3 etc.
- All the employees registered with ABC organization can start talking to each other.
Reason: They all belong to the same company.
- Few other employees can start talking with each other, too.
Reason: They belong to the parent company ABC, but still they have the right to start a conversation.
Now, let’s elaborate the concept here.
Consider ABC to be the core channel where all the users have to register after the successful login procedure. Within this core channel, where all users must be registered mandatory, users can register to other sub-channels like:
“EMP 1-EMP 2 CHANNEL”, based on whether they have their own private channels.
In short, there will be one core channel and ‘n’ number of sub-channels.
Switching Channels – How and When?
PubNub library provides access to numerous APIs which serves the purpose of:
- Registering PubNub services to the project.
- Registering a user to a channel.
- Get the list of users present in a particular channel.
- Unregister a user from a particular channel.
- Send message through a channel.
- Check message history on a particular channel.
- Listen to incoming messages.
- Always remember, the first step is the initialization of the PubNub services with respect to your application. This needs adding the ‘Publish’ and ‘Subscribe’ key that you received from the developer console to PubNub init() API.
- After successful login, register the user to the core channel. This allows the core channel know, how many users are registered and are currently online. You can show a list of users who are online.
- You can design a listing layout as per the application theme. As you can see in the diagram, assume that EMP 1,2,3,4 have already logged in, that means they are already registered with the core channel. Now, you can fetch list of all online users from core channel using here_now() API available.
- Sending chat request – You switch between a public and private chat channel. Public channel is the core channel whereas private channel is a dedicated chat channel between two users.
Diagram: User List As seen on EMP 1 UI
Let’s take a scenario.
- EMP 1 decides to start a private chat with EMP 2.
- EMP 1 clicks on EMP 2 element in the list. At this point, you create a new channel, say, “EMP1-EMP2 channel” and register both these users to this specific channel.
Now, both these users are available in the private channel and whatever messages are sent across, only goes through the private channel. All messages are safe and secure.
You have to write few codes to handle the channel switching.
What is a Channel in PubNub?
Channel is a space where PubNub allows you to store an array of messages and users associated. You need to think of a variable with some space allocated in memory. In this case, it is-
- One core channel space – the number of users registered and any message shared through the channel are stored.
- N’ number of private channels space – a channel is registered to two users (may vary in case of group chat channel) and messages transferred through the channel are stored within.
How does PubNub Work?
This is an overview of how PubNub works:
PubNub works within the PubNub DSN (Data Stream Network), which supports multiple protocols within, to support uninterrupted real time services anywhere, anytime.
PubNub supports WebSockets, Socket.io, MQTT, COMET, BOSH, SPDY, long polling and others, which enables efficiency of the services even during a network change or proxy environments.
The bottom line is, PubNub can work on any network as it doesn’t work on a single protocol and is independent of the network behavior since the PubNub DSN itself switches its protocol as required.This was one of the main reasons why PubNub was opted.
Find more details in the website.
There are some points to note:
- The trial version of PubNub limits for 100 devices. For complete details on pricing plans, please check the PubNub Pricing Plans.
- Please go through the API documentation of PubNub (link shared above) for accurate details about the available services.
- Adding the TLS and AES encryption to PubNub is always advisable. This makes your chat feature more secure.
Creation of Chat Feature in Oracle Siebel made Simple
PubNub makes real-time transmission simple. It helps in focusing on innovation and launching quickly, with the real-time APIs. You can build powerful and feature-rich real-time chat and collaboration applications which are powered by ?exible APIs and a global messaging infrastructure. They work on cross-platform such as web, iOS, Android etc. You are able to handle the resilient, global network infrastructure to deliver more engaging and immersive experiences.
Sr. Technical Engineer, RapidValue
The post PubNub – Creating Chat feature in Oracle Siebel Mobile App appeared first on RapidValue.This post was originally published on this site