move mutex

This commit is contained in:
Liam Stanley 2017-05-07 13:23:55 -04:00
parent 4942e00007
commit 327e795e49

View File

@ -279,6 +279,8 @@ func (c *Client) internalConnect(mock net.Conn) error {
var ctx context.Context
ctx, c.stop = context.WithCancel(context.Background())
c.mu.Unlock()
// Start read loop to process messages from the server.
errs := make(chan error, 3)
done := make(chan struct{}, 4)
@ -297,8 +299,6 @@ func (c *Client) internalConnect(mock net.Conn) error {
go c.pingLoop(errs, done, &wg, 1*time.Second)
}
c.mu.Unlock()
// Send a virtual event allowing hooks for successful socket connection.
c.RunHandlers(&Event{Command: INITIALIZED, Trailing: c.Server()})