Skip to content

Commit

Permalink
use std::dynamic_pointer_cast and guard wssession publish
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Feb 18, 2025
1 parent 9734faf commit 40bc3ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handler/handlerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,9 @@ class HandlerEngine::Private : public QObject

void publishSend(const std::shared_ptr<QObject> &target, const PublishItem &item, const QList<QByteArray> &exposeHeaders)
{
if(HttpSession *hs = dynamic_cast<HttpSession*>(target.get()))
if(auto hs = std::dynamic_pointer_cast<HttpSession>(target))
hs->publish(item, exposeHeaders);
else if(WsSession *s = dynamic_cast<WsSession*>(target.get()))
else if(auto s = std::dynamic_pointer_cast<WsSession>(target))
s->publish(item);
}

Expand Down
5 changes: 5 additions & 0 deletions src/handler/wssession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ void WsSession::ack(int reqId)

void WsSession::publish(const PublishItem &item)
{
const PublishFormat &f = item.format;

if(f.type != PublishFormat::WebSocketMessage)
return;

publishQueue += item;

if(!inProcessPublishQueue)
Expand Down

0 comments on commit 40bc3ae

Please sign in to comment.