Solved Client/Server Architecture of HTTP Communication
-
I could not find a better title but I spend days to find good architecture for my program, unfortunately could not invent a good one.
I have written an API and I have a client. My client application uses both QML and C++. QML is for pages and C++ backend. You may think this as something like Twitter.
Lets say I am on Page 1. If I click "Open Page 2" these happens:
- StackView pushes Page2 to stack
- Page 2 uses C++ function to send request to an API.
- When response comes, finished signal is emitted that data is ready to read.
- Related C++ slot emits a signal for QML after handling data.
- Then QML function populates data to view.
My problem is that I have to create new signal for each page/request. I don't think this is the right way of implementing this.
-
@LeLev Yeah, it should have been QML.
@dheerendra I think I should pass a reference to the request function and listen signals depend on their signature.
-
I am assuming each page is different. So each page need to have signal handler. Backend can be only one object which send the finished signal to page object. This how it should be. What is the individual signal you are talking about ? Is it UI side or backend side ?
-
@dheerendra Yeah, each page need to have a signal handler but I cannot send only one signal to related pages. I created a diagram to explain better.
In backend class I have different functions and signals for each page. For example
- Page 1 calls Backend::requestForPage1()
- It sends function pointer of related slot of page to Network class
- Callback slot emits responseReadyForPage1.
I have to create different signal for each page and this is so cumbersome and not optimum way of implementing this.
Maybe I should send JavaScript function object (aka. signal handler of page) to Backend request function but not sure this is the right way.
TLDR: @dheerendra said in Client/Server Architecture of HTTP Communication:
Backend can be only one object which send the finished signal to page object.
Cannot make only one signal that calls signal handler of page object. I do not want to make different signal for each page.
-
Hi,
@maydin said in Client/Server Architecture of HTTP Communication:I do not want to make different signal for each page.
BackEnd::requestPage(int pageNumber)
note: on your image you wrote 'UML' instead of 'Qml'
-
What is the difficulty in making only one signal and passing some reference I'd along with signal to differentiate which page is supposed to process this ?
-
@LeLev Yeah, it should have been QML.
@dheerendra I think I should pass a reference to the request function and listen signals depend on their signature.
-
Yes. You can make with request I'd. You can also work with objectname as well. You can move the issue to solved state as well.