淇锛氭秷鎭В鏋恇ug
git-svn-id: svn://47.119.165.148/zhub@122 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
14
zsub/zsub.go
14
zsub/zsub.go
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
"zhub/conf"
|
||||
)
|
||||
|
||||
@@ -134,7 +135,7 @@ func (c *ZConn) send(vs ...string) error {
|
||||
} else if len(vs) > 1 {
|
||||
data := "*" + strconv.Itoa(len(vs)) + "\r\n"
|
||||
for _, v := range vs {
|
||||
data += "$" + strconv.Itoa(len(v)) + "\r\n"
|
||||
data += "$" + strconv.Itoa(utf8.RuneCountInString(v)) + "\r\n"
|
||||
data += v + "\r\n"
|
||||
}
|
||||
bytes = []byte(data)
|
||||
@@ -249,7 +250,11 @@ func (s *ZSub) acceptHandler(c *ZConn) {
|
||||
case "*":
|
||||
n, _ := strconv.Atoi(string(line[1:]))
|
||||
for i := 0; i < n; i++ {
|
||||
reader.ReadLine()
|
||||
line, _, _ := reader.ReadLine()
|
||||
clen := 0
|
||||
if strings.EqualFold("$", string(line[:1])) {
|
||||
clen, _ = strconv.Atoi(string(line[1:]))
|
||||
}
|
||||
var vx = ""
|
||||
a:
|
||||
if v, prefix, _ := reader.ReadLine(); prefix {
|
||||
@@ -258,6 +263,11 @@ func (s *ZSub) acceptHandler(c *ZConn) {
|
||||
} else {
|
||||
vx += string(v)
|
||||
}
|
||||
if clen > utf8.RuneCountInString(vx) {
|
||||
vx += "\r\n"
|
||||
goto a
|
||||
}
|
||||
|
||||
rcmd = append(rcmd, vx)
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -229,6 +229,9 @@ func (s *ZSub) delay(rcmd []string, c *ZConn) {
|
||||
}
|
||||
delay.timer.Reset(time.Duration(t) * time.Millisecond)
|
||||
} else {
|
||||
if t < 0 {
|
||||
return
|
||||
}
|
||||
delay := &ZDelay{
|
||||
topic: rcmd[1],
|
||||
value: rcmd[2],
|
||||
|
||||
Reference in New Issue
Block a user