Skip to content

Commit a789819

Browse files
committed
Update websocket.cpp
1 parent 7d3e814 commit a789819

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

websocket/src/websocket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,6 @@ static dmExtension::Result OnUpdate(dmExtension::Params* params)
819819
{
820820
WebsocketConnection* conn = g_Websocket.m_Connections[i];
821821

822-
bool state_transition = conn->m_State != conn->m_PreviousState;
823-
conn->m_PreviousState = conn->m_State;
824-
825822
if (STATE_DISCONNECTED == conn->m_State)
826823
{
827824
{
@@ -845,7 +842,8 @@ static dmExtension::Result OnUpdate(dmExtension::Params* params)
845842
else if ((STATE_CONNECTED == conn->m_State) || (STATE_DISCONNECTING == conn->m_State))
846843
{
847844
DM_MUTEX_SCOPED_LOCK(conn->m_Mutex);
848-
if (state_transition && (STATE_CONNECTED == conn->m_State))
845+
// transitioned to the connected state?
846+
if ((conn->m_State != conn->m_PreviousState) && (STATE_CONNECTED == conn->m_State))
849847
{
850848
HandleCallback(conn, EVENT_CONNECTED, 0, 0);
851849
}
@@ -881,6 +879,8 @@ static dmExtension::Result OnUpdate(dmExtension::Params* params)
881879
}
882880
#endif
883881
}
882+
883+
conn->m_PreviousState = conn->m_State;
884884
}
885885

886886
return dmExtension::RESULT_OK;

0 commit comments

Comments
 (0)