淇锛氭秷鎭В鏋恇ug

git-svn-id: svn://47.119.165.148/zhub@122 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
lxy
2021-07-20 10:18:50 +00:00
parent b38fdfa058
commit ddbab4b725
2 changed files with 15 additions and 2 deletions

View File

@@ -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:

View File

@@ -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],