|
|
@ -54,8 +54,6 @@ type StarNotifyS struct {
|
|
|
|
listener net.Listener
|
|
|
|
listener net.Listener
|
|
|
|
isUDP bool
|
|
|
|
isUDP bool
|
|
|
|
Sync bool
|
|
|
|
Sync bool
|
|
|
|
// Stop 停止信 号
|
|
|
|
|
|
|
|
Stop chan int
|
|
|
|
|
|
|
|
// UDPConn UDP监听
|
|
|
|
// UDPConn UDP监听
|
|
|
|
UDPConn *net.UDPConn
|
|
|
|
UDPConn *net.UDPConn
|
|
|
|
// Online 当前链接是否处于活跃状态
|
|
|
|
// Online 当前链接是否处于活跃状态
|
|
|
@ -90,6 +88,9 @@ func (star *StarNotifyS) getName(conn string) string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (star *StarNotifyS) Stoped() <-chan struct{} {
|
|
|
|
|
|
|
|
return star.stopSign.Done()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetConnPool 获取所有Client端信息
|
|
|
|
// GetConnPool 获取所有Client端信息
|
|
|
|
func (star *StarNotifyS) GetConnPool() []SMsg {
|
|
|
|
func (star *StarNotifyS) GetConnPool() []SMsg {
|
|
|
@ -233,9 +234,8 @@ func (star *StarNotifyS) starinits() {
|
|
|
|
star.FuncLists = make(map[string]func(SMsg) string)
|
|
|
|
star.FuncLists = make(map[string]func(SMsg) string)
|
|
|
|
star.nickName = make(map[string]string)
|
|
|
|
star.nickName = make(map[string]string)
|
|
|
|
star.lockPool = make(map[string]SMsg)
|
|
|
|
star.lockPool = make(map[string]SMsg)
|
|
|
|
star.Stop = make(chan int, 5)
|
|
|
|
|
|
|
|
star.Online = false
|
|
|
|
star.Online = false
|
|
|
|
star.Queue.RestoreDuration(time.Second * 2)
|
|
|
|
star.Queue.RestoreDuration(time.Millisecond * 50)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewNotifyS 开启一个新的Server端通知
|
|
|
|
// NewNotifyS 开启一个新的Server端通知
|
|
|
@ -443,10 +443,13 @@ func (star *StarNotifyS) notify() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data, err := star.Queue.RestoreOne()
|
|
|
|
data, err := star.Queue.RestoreOne()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
time.Sleep(time.Microsecond * 2)
|
|
|
|
time.Sleep(time.Millisecond * 500)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mode, key, value := star.analyseData(string(data.Msg))
|
|
|
|
mode, key, value := star.analyseData(string(data.Msg))
|
|
|
|
|
|
|
|
if mode == key && mode == value && mode == "" {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
var rmsg SMsg
|
|
|
|
var rmsg SMsg
|
|
|
|
if !star.isUDP {
|
|
|
|
if !star.isUDP {
|
|
|
|
rmsg = SMsg{data.Conn.(net.Conn), key, value, nil, nil, mode, nil, star.setNickName, star.getName}
|
|
|
|
rmsg = SMsg{data.Conn.(net.Conn), key, value, nil, nil, mode, nil, star.setNickName, star.getName}
|
|
|
@ -507,13 +510,13 @@ func (star *StarNotifyS) notify() {
|
|
|
|
|
|
|
|
|
|
|
|
func (star *StarNotifyS) analyseData(msg string) (mode, key, value string) {
|
|
|
|
func (star *StarNotifyS) analyseData(msg string) (mode, key, value string) {
|
|
|
|
slice := strings.SplitN(msg, "||", 3)
|
|
|
|
slice := strings.SplitN(msg, "||", 3)
|
|
|
|
|
|
|
|
if len(slice) < 3 {
|
|
|
|
|
|
|
|
return "", "", ""
|
|
|
|
|
|
|
|
}
|
|
|
|
return slice[0], star.trim(slice[1]), slice[2]
|
|
|
|
return slice[0], star.trim(slice[1]), slice[2]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ServerStop 用于终止Server端运行
|
|
|
|
// ServerStop 用于终止Server端运行
|
|
|
|
func (star *StarNotifyS) ServerStop() {
|
|
|
|
func (star *StarNotifyS) ServerStop() {
|
|
|
|
star.cancel()
|
|
|
|
star.cancel()
|
|
|
|
star.Stop <- 1
|
|
|
|
|
|
|
|
star.Stop <- 1
|
|
|
|
|
|
|
|
star.Stop <- 1
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|