support udp
This commit is contained in:
@@ -21,6 +21,7 @@ type StarNotifyC struct {
|
||||
// UseChannel 是否使用channel作为信息传递
|
||||
UseChannel bool
|
||||
notifychan chan int
|
||||
isUDP bool
|
||||
// Queue 是用来处理收发信息的简单消息队列
|
||||
Queue *starainrt.StarQueue
|
||||
}
|
||||
@@ -63,6 +64,10 @@ func NewNotifyC(netype, value string) (*StarNotifyC, error) {
|
||||
var err error
|
||||
var star StarNotifyC
|
||||
star.starinitc()
|
||||
star.isUDP = false
|
||||
if strings.Index(netype, "udp") >= 0 {
|
||||
star.isUDP = true
|
||||
}
|
||||
star.connc, err = net.Dial(netype, value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -116,6 +121,10 @@ func (star *StarNotifyC) cnotify() {
|
||||
time.Sleep(time.Millisecond * 20)
|
||||
continue
|
||||
}
|
||||
if data.Msg == "b612ryzstop" {
|
||||
star.clientStopSign <- 0
|
||||
return
|
||||
}
|
||||
strs := strings.SplitN(data.Msg, "||", 2)
|
||||
if len(strs) < 2 {
|
||||
continue
|
||||
@@ -137,6 +146,9 @@ func (star *StarNotifyC) cnotify() {
|
||||
|
||||
// ClientStop 终止client端运行
|
||||
func (star *StarNotifyC) ClientStop() {
|
||||
if star.isUDP {
|
||||
star.Send("b612ryzstop")
|
||||
}
|
||||
star.clientStopSign <- 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user