Skip to content

Commit

Permalink
Setting state to disconnected instead of connecting when DISCONNECTED…
Browse files Browse the repository at this point in the history
… msg received
  • Loading branch information
sacOO7 committed Aug 30, 2024
1 parent 83d180d commit 8dabea2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ably/realtime_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func (c *Connection) eventloop() {
c.mtx.Unlock()
return
}
// RTN23a
// RTN23a, RTN15a
c.lockSetState(ConnectionStateDisconnected, err, 0)
c.mtx.Unlock()
arg := connArgs{
Expand Down Expand Up @@ -871,15 +871,15 @@ func (c *Connection) eventloop() {
return
}
// RTN15h2, RTN22a
c.setState(ConnectionStateConnecting, newErrorFromProto(msg.Error), 0)
c.setState(ConnectionStateDisconnected, newErrorFromProto(msg.Error), 0)
c.reauthorize(connArgs{
lastActivityAt: lastActivityAt,
connDetails: connDetails,
})
return
}
// RTN15h3
c.setState(ConnectionStateConnecting, newErrorFromProto(msg.Error), 0)
c.setState(ConnectionStateDisconnected, newErrorFromProto(msg.Error), 0)
c.reconnect(connArgs{
lastActivityAt: lastActivityAt,
connDetails: connDetails,
Expand Down
5 changes: 2 additions & 3 deletions ably/realtime_conn_spec_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func Test_RTN4a_ConnectionEventForStateChange(t *testing.T) {
"fake disconnection failed: %v", err)

ablytest.Soon.Recv(t, nil, changes, t.Fatalf)

})

t.Run(fmt.Sprintf("on %s", ably.ConnectionStateSuspended), func(t *testing.T) {
Expand Down Expand Up @@ -1772,7 +1771,7 @@ func TestRealtimeConn_RTN15h3_Success(t *testing.T) {
ablytest.Instantly.Recv(t, &change, stateChanges, t.Fatalf)

assert.Equal(t, ably.ConnectionEventConnected, change.Event,
"expected UPDATED event; got %v", change)
"expected CONNECTED event; got %v", change)

// Expect no further events.break
ablytest.Instantly.NoRecv(t, nil, stateChanges, t.Fatalf)
Expand Down Expand Up @@ -1805,7 +1804,7 @@ func TestRealtimeConn_RTN15h_Integration_ClientInitiatedAuth(t *testing.T) {
assert.NoError(t, err)

for i := 0; i < 3; i++ {
err = ablytest.Wait(ablytest.ConnWaiter(realtime, nil, ably.ConnectionEventConnecting), nil)
err = ablytest.Wait(ablytest.ConnWaiter(realtime, nil, ably.ConnectionEventDisconnected), nil)
var errorInfo *ably.ErrorInfo
assert.Error(t, err)
assert.ErrorAs(t, err, &errorInfo)
Expand Down

0 comments on commit 8dabea2

Please sign in to comment.