PDA

View Full Version : Networking implementation question



Talei
13th October 2012, 20:05
Hello,
I have a question regarding implementation of the networking in my application.

Application that I develop needs to perform various actions, like login, send file, get file, get file info etc. These action can also have more then one "sub action" i.e. login require 2 request to the server etc.

I'm using asynchronous approach with the QNetworkManager and my question:

Because of the performance reason I reuse QNetworkManager for all my "network actions" and I connect finished() signal to the same function. In that function I have helper variables like i.e. isLogin to determine what current reply from the server is for. Over the time that function has many if's i.e.

if (isLogin)
processLogin();
etc.

Is there any other approach to eliminate those state conditions?

How about QStateMachine?

Any advice is more then welcome.

wysota
13th October 2012, 20:41
QStateMachine is probably an overkill here but implementing a simple state machine tracking the state of the communication is a good idea.