V
V
Vitaly Azovsky2015-09-11 09:33:55
JavaScript
Vitaly Azovsky, 2015-09-11 09:33:55

How to organize the transfer of information over the network in a Qt application?

Good day.
There were several questions about the architecture of applications running over the network.
Let's say we have a task.
There is a base class room, from which the classes Bedroom and Living room are inherited. There is a base class Book, and subclasses Notebook, art book, etc.
There is an Agent class that monitors, moves and creates all this business.
The bottom line is this, the server receives information from other sources about some movement of objects somewhere.
When the server starts, the Agent creates the necessary rooms and waits for information about the books. A new book came into the room, the agent created it, and put it in the room. The book moved - the agent took it out of one room and put it in another. The agent has access to all methods, both books and rooms. To display all this information, I created a small window where I placed a list of rooms in a QListWidget and a QListWidget for books in the selected room. I pass the agent pointer to this window class, and inside the class I already call the methods I need to display information.
Everything is clear here, and everything works.
And now I need to pass all this information to the client.
The client essentially consists of one window, like a server, where all the information with rooms and books should be displayed.
Here are the questions, how best to organize such a task?
I see several options.
1. At the client to create the same classes of rooms and books. And as soon as the infa came to the server, the agent processed it, and practically gave it to the client in its naked form, he already processes it. I think the option, to put it mildly, is not very good, because there is no need for a server as such.
2. Serialization. I can’t say anything, I’m not yet familiar with serialization, so I’m asking for advice, is it possible to process all the information through it?
3. Transfer different maps. Something changed on the server, created a new map - passed it to the client. Everything is fine, but there is a small nuance. The rooms and books themselves, in addition to the name and current values, have more information that would not be bad to look at. Rooms - type of rooms. for books - the type of books and the author, if any, and so on.
In the server, thanks to the agent, I simply chose a room, and pulled out information through the agent, but here it doesn’t work out like that, I have to at least fence QList> and so on.
So it turns out that I still can not come to a solution to the problem. I ask for your help.
Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stockholm Syndrome, 2019-04-08
@CodeInMyHeart

what are you doing, these are the basics

A
Armenian Radio, 2015-09-11
@gbg

The simplest option is a protocol of one request from the client and two responses from the server.
Query:
Give the state of everything.
Answers
- no changes
- new state of books - rooms.
At the protocol development stage, it makes no sense to think about implementation details (QList is not QList), this should be done by assembling at least a framework.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question