skip to content »

ik-kem.ru

I want to open xxx chat line

When an app needs to send data to the server, or fetch from it, it makes the proper request and after a while the data has been returned.That happens several times during the app runtime period. What if, for example, an app should show some sort of a news feed that needs to be updated all the time?

On my part, I’ll give you the big picture in simple words, so you are able to better understand what comes later.Or what if real-time conversation between users should be supported as an app feature?A solution would be to let the app ask for new data the server quite frequently, so anything new to be grabbed as soon as possible.Thankfully, there’s a better solution when it’s necessary to receive data from a server instantly (every time such data becomes available), and without having the app to send any request to the server at all.That solution is based on making use of websockets, and it totally erases the couple aforementioned issues.The websocket communication relies on the client-server logic, where a persistent connection between a server and a client always exists.

To be more precise, the server “opens” a dedicated port where clients get connected to it.

Besides sending and getting messages, we’ll add a couple of other interesting features to the app: We’ll display a popup label when a new user is getting connected to the chat, or an existing one leaves it.

Furthermore, when one or more users are typing messages, the other users will be notified for that by a label that will appear right above the textview used to write messages.

Besides that, the term “client” refers to any application that can get connected to a server: Web, mobile or desktop app.

However, by saying “client” in this text we’ll be referring to i OS apps, and to our demo app more specifically later on.

Just note that even if you get the final project to test the app without getting involved in the implementation at all, the server part is something you have to mandatorily do if you want to see the app running.