Skip to content

Commit

Permalink
Call OnConnect after a connection regardless of events
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-urdin committed Feb 23, 2023
1 parent 9c08d07 commit 5eabf96
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ func (c *Client) startReadLoop(reader *EventStreamReader) (chan *Event, chan err
}

func (c *Client) readLoop(reader *EventStreamReader, outCh chan *Event, erChan chan error) {
if !c.Connected && c.connectedcb != nil {
c.Connected = true
c.connectedcb(c)
}

for {
// Read each new line and process the type of event
event, err := reader.ReadEvent()
Expand All @@ -221,11 +226,6 @@ func (c *Client) readLoop(reader *EventStreamReader, outCh chan *Event, erChan c
return
}

if !c.Connected && c.connectedcb != nil {
c.Connected = true
c.connectedcb(c)
}

// If we get an error, ignore it.
var msg *Event
if msg, err = c.processEvent(event); err == nil {
Expand Down

0 comments on commit 5eabf96

Please sign in to comment.