|
@@ -47,7 +47,7 @@ func (s *Server) Start() error {
|
|
|
func (s *Server) Stop() {
|
|
|
s.clients.Iterator(func(k interface{}, v interface{}) bool {
|
|
|
client := v.(*Client)
|
|
|
- client.closeConnection()
|
|
|
+ close(client.closeChan)
|
|
|
return true
|
|
|
})
|
|
|
_ = s.server.Close()
|
|
@@ -67,11 +67,13 @@ func (s *Server) onClientConnect(conn *gtcp.Conn) {
|
|
|
_ = s.gateWay.SubDeviceLogin(g.Cfg().GetString("Sparrow.DeviceCode"), id)
|
|
|
s.clients.Set(id, c)
|
|
|
}
|
|
|
- time.Sleep(10 * time.Second)
|
|
|
err := c.SendGetAddress()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ time.Sleep(10 * time.Second)
|
|
|
+
|
|
|
go c.SendLoop()
|
|
|
|
|
|
go c.GetActivePower()
|