-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Every handler connect signal data(QByteArray) and end() of every request #59
Comments
I didn't quite understand what is the question. Can you elaborate a little more? Even if I didn't understand the question, it reminds me of the differences between Tufão 0.x and 1.x. |
Tks for reply me !!, I have an example here with 2 handlers: Handler1, Handler2 class Handler1 : public Tufao::AbstractHttpServerRequestHandler class Handler2 : public Tufao::AbstractHttpServerRequestHandler In slot handleRequest, I have: In slot onEndRequest(), I log this: In main: So every request comes to handler will go through handleRequest, right? Request to /handler1 comes to handleRequest of Handler1, and request to /handler2 comes to handleRequest of Handler2. And when request ends, it will go to onEndRequest(). First time I request to /handler1. it logs: Second time, it logs double: Third time, it becomes trible: And request to /handler2, it logs: It seems the previous requests haven't ended yet. They still emit the signal end() and the handlers still catch this signal. Can you explain for me this situation ? Tks alot |
Well, this is one of the differences between Tufão 0.x and Tufão 1.x and I used an alternative approach in Tufão 1.x because I acknowledged the lack of intuitiveness:
To understand what it is happening, you just need to realize that Currently, this is what is happening to your code:
Was I clear? Fix: On the Alternative fix: Use Tufão 1.x, as it will automatically disconnects all slots connected to the |
Thank you so so much. Unfortunately, I must use Qt 4.7 so I can't use Tufao 1.x. But if I don't handle the ready signal, how can I clear all previous connections ? Can you give me an example |
There isn't much secret here. The trick is to ensure there is only one signal-slot connection. You can even use Qt::UniqueConnection, but I cannot recommend this as a general case because it's very easy to create bugs. You must be careful and understand what you're doing because HTTP is stateless and data artifacts from one pair of request and response must not escape to another unrelated pair of request and response. Anyway, in
I'm on the middle of a timeline now, so I cannot give much resources to this issue now. If you remind me on January 2 (or later), I believe I'll have the time to elaborate an example. |
Thank you, I appreciate it a lot |
Hi everyone,
I have many handlers inherit Tufao::AbstractHttpServerRequestHandler. In each handler, I have slots: onData(QByteArray) connect with signal data(QByteArray) and onEndRequest() connect with signal end() of each request comes to handler.
I also have router to route request to right handler.
But every time new request comes, it emits signal data(QByteArray), signal end() and all of my handlers catch these signal and connect to their slots.
Can you have a try to give an answer? thanks a lot.
Edited: I use Tufao on branch 0.x for Qt 4.7
The text was updated successfully, but these errors were encountered: