Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ type Client struct {
mu sync.Mutex
EncodingBase64 bool
Connected bool
AutoReconnect bool
}

// NewClient creates a new client
func NewClient(url string, opts ...func(c *Client)) *Client {
c := &Client{
URL: url,
Connection: &http.Client{},
AutoReconnect: false,
Headers: make(map[string]string),
subscribed: make(map[chan *Event]chan struct{}),
maxBufferSize: 1 << 16,
Expand Down Expand Up @@ -214,8 +216,10 @@ func (c *Client) readLoop(reader *EventStreamReader, outCh chan *Event, erChan c
event, err := reader.ReadEvent()
if err != nil {
if err == io.EOF {
erChan <- nil
return
if !c.AutoReconnect {
erChan <- nil
return
}
}
// run user specified disconnect function
if c.disconnectcb != nil {
Expand Down