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