1
0
forked from x/icebergs
icebergs/base/web/stream.go
2021-05-25 22:24:50 +08:00

22 lines
421 B
Go

package web
import (
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
)
type Buffer struct {
m *ice.Message
n string
}
func (b *Buffer) Write(buf []byte) (int, error) {
b.m.Cmd(SPACE, b.n, "grow", string(buf))
return len(buf), nil
}
func (b *Buffer) Close() error { return nil }
func PushStream(m *ice.Message) {
m.Option(cli.CMD_OUTPUT, &Buffer{m: m, n: m.Option(ice.MSG_DAEMON)})
}