This commit is contained in:
crusader 2018-04-27 16:22:23 +09:00
parent d786bc3281
commit 973fb2cb53
2 changed files with 10 additions and 4 deletions

View File

@ -64,8 +64,9 @@ func (c *Connectors) Connect() (readChan <-chan []byte, writeChan chan<- []byte,
c.crw.DisconnectedChan = c.disconnectedChan c.crw.DisconnectedChan = c.disconnectedChan
c.crw.ReconnectedChan = c.reconnectedChan c.crw.ReconnectedChan = c.reconnectedChan
c.stopWg.Add(2) c.stopWg.Add(1)
go c.handleReconnect() go c.handleReconnect()
c.stopWg.Add(1)
go c.crw.HandleConnection(conn) go c.crw.HandleConnection(conn)
return c.readChan, c.writeChan, nil return c.readChan, c.writeChan, nil
@ -95,7 +96,9 @@ func (c *Connectors) onDisconnected() {
onDisconnected := c.OnDisconnected onDisconnected := c.OnDisconnected
if nil != onDisconnected { if nil != onDisconnected {
onDisconnected(c) go func() {
onDisconnected(c)
}()
} }
} }

View File

@ -101,8 +101,9 @@ func (c *Connectors) Connect() (readChan <-chan []byte, writeChan chan<- []byte,
c.crw.DisconnectedChan = c.disconnectedChan c.crw.DisconnectedChan = c.disconnectedChan
c.crw.ReconnectedChan = c.reconnectedChan c.crw.ReconnectedChan = c.reconnectedChan
c.stopWg.Add(2) c.stopWg.Add(1)
go c.handleReconnect() go c.handleReconnect()
c.stopWg.Add(1)
go c.crw.HandleConnection(conn) go c.crw.HandleConnection(conn)
return c.readChan, c.writeChan, nil return c.readChan, c.writeChan, nil
@ -132,7 +133,9 @@ func (c *Connectors) onDisconnected() {
onDisconnected := c.OnDisconnected onDisconnected := c.OnDisconnected
if nil != onDisconnected { if nil != onDisconnected {
onDisconnected(c) go func() {
onDisconnected(c)
}()
} }
} }