feat: 合并代码
This commit is contained in:
@@ -36,12 +36,11 @@ func NewMMLClient(ip string) (*MMLClient, error) {
|
||||
fmt.Fprintln(conn, passwordMML)
|
||||
|
||||
// 发送后等待
|
||||
sleepTime := conf.Get("mml.sleep").(int)
|
||||
awaitTime := time.Duration(sleepTime) * time.Millisecond
|
||||
awaitTime := time.Duration(300) * time.Millisecond
|
||||
time.Sleep(awaitTime)
|
||||
|
||||
// 读取内容
|
||||
buf := make([]byte, 1024*8)
|
||||
buf := make([]byte, 1024*1024*1)
|
||||
n, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -70,7 +69,7 @@ func (c *MMLClient) Send(msg string) error {
|
||||
|
||||
// 封装Receive函数,用于从TCP连接中接收数据
|
||||
func (c *MMLClient) Receive() (string, error) {
|
||||
buf := make([]byte, 1024*8)
|
||||
buf := make([]byte, 1024*1024*1)
|
||||
n, err := c.reader.Read(buf)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
@@ -78,7 +77,7 @@ func (c *MMLClient) Receive() (string, error) {
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
c.size += n
|
||||
return string(buf[0:n]), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user