Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Fixed bug in sending unencrypted messages. #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions QPubNub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ void QPubNub::publish(const QString& channel, const QJsonValue& value) {
}

QByteArray message;
QString publishURL;
#ifdef Q_PUBNUB_CRYPT
if (!m_cipherKey.isEmpty()) {
QPubNubCrypt crypt(m_cipherKey);
Expand All @@ -143,14 +144,16 @@ void QPubNub::publish(const QString& channel, const QJsonValue& value) {
emit error(errorString, errorCode);
return;
}
publishURL = publishUrl("\""+message+"\"", channel);
} else {
#endif // Q_PUBNUB_CRYPT
message = toByteArray(value);
publishURL = publishUrl(message, channel);
#ifdef Q_PUBNUB_CRYPT
}
#endif

QNetworkReply * reply = sendRequest(publishUrl("\""+message+"\"", channel));
QNetworkReply * reply = sendRequest(publishURL);
// This can't be connected using the new syntax, cause the signal and error property have the same name "error"
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
connect(reply, &QNetworkReply::finished, this, &QPubNub::publishFinished);
Expand Down Expand Up @@ -225,12 +228,16 @@ void QPubNub::onSubscribeReadyRead() {
m_timeToken = timeTokenElement.toString();
QJsonValue channelListString = response.at(2);
QStringList channels;
QJsonArray messages = firstElement.toArray();
if (channelListString.isString()) {
channels = channelListString.toString().split(',');
} else {
channels << m_channelUrlPart;
int len = messages.isEmpty() ? 0 : messages.size();
for (int i = 0; i < len; i++)
{
channels << m_channelUrlPart;
}
}
QJsonArray messages = firstElement.toArray();
if (messages.isEmpty()) {
emit connected();
} else {
Expand Down