代码拉取完成,页面将自动刷新
package boxio
import (
"io"
)
// MessageSizeMax is a soft (recommended) maximum for network messages.
// One can write more, as the interface is a stream. But it is useful
// to bunch it up into multiple read/writes when the whole message is
// a single, large serialized object.
const MessageSizeMax = 1 << 22 // 4 MB
var (
BoxMsgIO = &BoxDataIOData{}
)
type BoxDataIOData struct {
}
// ReadMessage 读取一个BoxData消息
func (that *BoxDataIOData) ReadMessage(stream io.Reader, msg BoxData) error {
// 最大读取4M数据
r := NewBoxReader(stream, MessageSizeMax)
err := r.ReadBox(msg)
if err != nil {
return err
}
return nil
}
func (that *BoxDataIOData) WriteMessage(stream io.Writer, msg BoxData, tryCount int) error {
if tryCount <= 0 {
tryCount = 1
}
for i := 1; i <= tryCount; i++ {
w := NewBoxWriter(stream)
err := w.WriteBox(msg)
if err != nil {
if i < tryCount {
continue
}
return err
}
break
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。