bug fix
This commit is contained in:
@@ -29,6 +29,8 @@ type StarNotifyS struct {
|
||||
isUDP bool
|
||||
// UDPConn UDP监听
|
||||
UDPConn *net.UDPConn
|
||||
// Online 当前链接是否处于活跃状态
|
||||
Online bool
|
||||
}
|
||||
|
||||
// SMsg 指明当前服务端被通知的关键字
|
||||
@@ -68,6 +70,7 @@ func (star *StarNotifyS) starinits() {
|
||||
star.udpPool = make(map[string]*net.UDPAddr)
|
||||
star.FuncLists = make(map[string]func(SMsg) string)
|
||||
star.connPool = make(map[string]net.Conn)
|
||||
star.Online = false
|
||||
}
|
||||
|
||||
// NewNotifyS 开启一个新的Server端通知
|
||||
@@ -96,12 +99,13 @@ func doudps(netype, value string) (*StarNotifyS, error) {
|
||||
go func() {
|
||||
<-star.serverStopSign
|
||||
star.notifychan <- 1
|
||||
star.notifychan <- 1
|
||||
star.notifychan <- 2
|
||||
for k, v := range star.udpPool {
|
||||
star.UDPConn.WriteToUDP(star.Queue.BuildMessage("b612ryzstop"), v)
|
||||
delete(star.connPool, k)
|
||||
}
|
||||
star.UDPConn.Close()
|
||||
star.Online = false
|
||||
return
|
||||
}()
|
||||
for {
|
||||
@@ -117,6 +121,7 @@ func doudps(netype, value string) (*StarNotifyS, error) {
|
||||
}
|
||||
}
|
||||
}()
|
||||
star.Online = true
|
||||
return &star, nil
|
||||
}
|
||||
|
||||
@@ -133,13 +138,14 @@ func notudps(netype, value string) (*StarNotifyS, error) {
|
||||
for {
|
||||
go func() {
|
||||
<-star.serverStopSign
|
||||
star.notifychan <- 1
|
||||
star.notifychan <- 1
|
||||
star.notifychan <- 3
|
||||
star.notifychan <- 4
|
||||
for k, v := range star.connPool {
|
||||
v.Close()
|
||||
delete(star.connPool, k)
|
||||
}
|
||||
listener.Close()
|
||||
star.Online = false
|
||||
return
|
||||
}()
|
||||
|
||||
@@ -170,6 +176,7 @@ func notudps(netype, value string) (*StarNotifyS, error) {
|
||||
star.connPool[conn.RemoteAddr().String()] = conn
|
||||
}
|
||||
}()
|
||||
star.Online = true
|
||||
return &star, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user