Let's talk about the data interaction and protocol between the front-end and the back-end

Let's talk about the data interaction and protocol between the front-end and the back-end
[[161047]]

At present, except for some very simple non-Internet applications (such as calculators, alarm clocks, etc.), almost all applications are Internet applications (such as news clients, WeChat, etc.). These app clients are basically only responsible for user interaction and data collection and display. The real data and services are stored in the cloud.

So how does the mobile terminal exchange data with the backend and display it? Let's make an analogy. In fact, the whole process is the same as going to a barbecue restaurant to eat skewers.

Take any news client as an example. When the user refreshes the page (you have the idea of ​​eating barbecue), the client starts to organize data requests (you start to get dressed, wash your face and dress up, and think about which restaurant to go to). When the user interface starts to show loading (at this time you are walking on the way to "Auntie Ma's BBQ Restaurant"), after a few hundred milliseconds, the requested data has reached the server (you are already sitting at the table of Auntie Ma's BBQ Restaurant). The server starts to check what data the client wants to request, whether it is for the financial channel or the car channel (the waiter hands you the menu and asks you what you want to eat). The server understands the client's idea and starts to prepare data (you ordered 20 skewers of meat and 10 kidneys). The server sees that you requested data from the car channel and the financial channel (the shirtless skewers chef starts to grill these 20 skewers and 10 kidneys), and returns it to the waiter. The waiter trots all the way and hands you the skewers and kidneys. At this time, it is equivalent to that the data has been transmitted back to the client, the client loading disappears, and you see the latest data of the two channels.

What is the format of data transmitted between the client and the server?

There are usually two popular practices now. One is to transmit binary data (binary data means that when you open this file, you can only see a string of numbers composed of 0 and 1, which cannot be associated with any letters you know in your life) similar to PB (Protocol Buffer, a data transmission protocol defined by Google, famous for its simplicity, bandwidth saving and ease of use). The advantage of this format is that the package is small and repeated fields are saved. The other is JSON (JavaScript Object Notation), which is also a lightweight data transmission format. It organizes data with a bunch of brackets. Unlike binary, this format is human-readable and relatively lightweight, so it also has a large number of application scenarios. The following data is in JSON format. To put it simply, people corresponds to three people, and the three people are the people in the three curly brackets between the brackets.

To sum up, it is very simple. The mobile terminal makes a request, and the server organizes the data and sends it to you. For different formats, the mobile terminal parses and displays it by itself, and the job is done. In fact, this is not only true for mobile terminals, but also for front-end web pages and back-ends, and between back-ends. As for what happened during the transmission process, we will find an opportunity to talk about it in detail.

<<:  Establishment of internal system of startup companies

>>:  A look at the tech products and services that disappeared in 2015

Recommend

Tianzhou-5 docked successfully! Setting a new record for China's space program!

Image source: Xinhua News Agency reporter Yang Gu...

Interview with Zenny Chen: iOS developers should pay attention to Metal

[[120974]] CocoaChina: How did you get involved i...

Outrageous! These animals use their noses to walk and their ears to fly!

Not long ago, a shocking news came out from the C...

Download Douyin Live Streaming Crash Course Baidu Cloud

Download Douyin Live Streaming Crash Course Baidu...

Daily Fresh’s private domain growth strategy

Recently, fresh food e-commerce has ushered in a ...

What is the specific function of Wenchang Tower?

1. If you can concentrate, your luck in studying ...

iOS development · Macros and methods related to iPhone X adaptation

After a long time, today I finally have time to s...