Skip to content

Commit

Permalink
emit TestWebSocket signals
Browse files Browse the repository at this point in the history
  • Loading branch information
sima committed Dec 11, 2023
1 parent 0c77eed commit a18df3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/cpp/proxy/testwebsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ WebSocket::ErrorCondition TestWebSocket::errorCondition() const
return d->errorCondition;
}

void TestWebSocket::emit_readyRead(){
this->readyRead();
}

void TestWebSocket::emit_framesWritten(int count, int contentBytes){
this->framesWritten(count, contentBytes);
}

void TestWebSocket::emit_writeBytesChanged(){
this->writeBytesChanged();
}

void TestWebSocket::writeFrame(const Frame &frame)
{
Frame tmp = frame;
Expand All @@ -296,13 +308,13 @@ void TestWebSocket::writeFrame(const Frame &frame)

d->inFrames += tmp;

this->framesWritten(1, tmp.data.size());
this->readyRead();
QMetaObject::invokeMethod(this, "emit_framesWritten", Qt::QueuedConnection, Q_ARG(int, 1), Q_ARG(int, tmp.data.size()));
QMetaObject::invokeMethod(this, "emit_readyRead", Qt::QueuedConnection);
}

WebSocket::Frame TestWebSocket::readFrame()
{
this->writeBytesChanged();
QMetaObject::invokeMethod(this, "emit_writeBytesChanged", Qt::QueuedConnection);

return d->inFrames.takeFirst();
}
Expand Down
3 changes: 3 additions & 0 deletions src/cpp/proxy/testwebsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class TestWebSocket : public WebSocket
virtual QString peerCloseReason() const;
virtual ErrorCondition errorCondition() const;

virtual void emit_readyRead();
virtual void emit_framesWritten(int count, int contentBytes);
virtual void emit_writeBytesChanged();
virtual void writeFrame(const Frame &frame);
virtual Frame readFrame();
virtual void close(int code = -1, const QString &reason = QString());
Expand Down

0 comments on commit a18df3d

Please sign in to comment.