Skip to content

Commit

Permalink
sockjs: handle websocket setup properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Jun 9, 2021
1 parent cb41d9c commit d068c3c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/proxy/sockjssession.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2017 Fanout, Inc.
* Copyright (C) 2015-2021 Fanout, Inc.
*
* This file is part of Pushpin.
*
Expand Down Expand Up @@ -264,7 +264,6 @@ class SockJsSession::Private : public QObject
}
else
{
connect(sock, &ZWebSocket::connected, this, &Private::sock_connected);
connect(sock, &ZWebSocket::readyRead, this, &Private::sock_readyRead);
connect(sock, &ZWebSocket::framesWritten, this, &Private::sock_framesWritten);
connect(sock, &ZWebSocket::closed, this, &Private::sock_closed);
Expand Down Expand Up @@ -447,11 +446,15 @@ class SockJsSession::Private : public QObject

sock->respondSuccess(reason, headers);

state = Connected;

if(mode == WebSocketFramed)
{
Frame f(Frame::Text, "o", false);
pendingWrites += WriteItem(WriteItem::Transport);
sock->writeFrame(f);

keepAliveTimer->start(KEEPALIVE_TIMEOUT * 1000);
}
}
}
Expand Down Expand Up @@ -950,16 +953,6 @@ private slots:
}
}

void sock_connected()
{
state = Connected;

if(mode == WebSocketFramed)
keepAliveTimer->start(KEEPALIVE_TIMEOUT * 1000);

emit q->connected();
}

void sock_readyRead()
{
if(mode == WebSocketFramed)
Expand Down

0 comments on commit d068c3c

Please sign in to comment.