mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt space
This commit is contained in:
parent
c0e59eec3c
commit
a0ec7370b1
@ -109,8 +109,9 @@ func (f *Frame) parse(m *ice.Message, h, line string) string {
|
||||
func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
|
||||
f.ps1 = kit.Simple(m.Confv(PROMPT, kit.Keym(PS1)))
|
||||
f.ps2 = kit.Simple(m.Confv(PROMPT, kit.Keym(PS2)))
|
||||
m.Optionv(MESSAGE, m)
|
||||
m.I, m.O = f.stdin, f.stdout
|
||||
m.Optionv(MESSAGE, m)
|
||||
m.Sleep("300ms")
|
||||
ps, bio := f.ps1, bufio.NewScanner(f.stdin)
|
||||
for f.prompt(m, ps...); f.stdin != nil && bio.Scan(); f.prompt(m, ps...) {
|
||||
if len(bio.Text()) == 0 && h == STDIO {
|
||||
|
@ -38,6 +38,10 @@ func _client_dial(m *ice.Message, arg ...string) {
|
||||
defer c.Close()
|
||||
}
|
||||
switch cb := m.OptionCB("").(type) {
|
||||
case func(*ice.Message, net.Conn):
|
||||
if !m.Warn(e) {
|
||||
cb(m, c)
|
||||
}
|
||||
case func(net.Conn):
|
||||
if !m.Warn(e) {
|
||||
cb(c)
|
||||
|
@ -62,7 +62,7 @@ func _dream_show(m *ice.Message, name string) {
|
||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
||||
defer ToastProcess(m)()
|
||||
bin := kit.Select(os.Args[0], cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN))
|
||||
m.Cmd(cli.DAEMON, bin, SPACE, tcp.DIAL, ice.DEV, ice.OPS, m.OptionSimple(mdb.NAME, RIVER), cli.DAEMON, ice.OPS)
|
||||
m.Cmd(cli.DAEMON, bin, SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.TYPE, WORKER, m.OptionSimple(mdb.NAME, RIVER), cli.DAEMON, ice.OPS)
|
||||
m.Sleep3s()
|
||||
}
|
||||
func _dream_template(m *ice.Message, p string) {
|
||||
|
@ -24,7 +24,7 @@ func _serve_start(m *ice.Message) {
|
||||
m.Option(tcp.PORT, m.Cmdx(tcp.PORT, aaa.RIGHT))
|
||||
}
|
||||
m.Target().Start(m, m.OptionSimple(tcp.HOST, tcp.PORT)...)
|
||||
m.Sleep30ms().Go(func() { m.Cmd(BROAD, SERVE) })
|
||||
m.Sleep30ms().Go(func() { m.Cmd(BROAD, SERVE, m.OptionSimple(tcp.PORT)) })
|
||||
for _, v := range kit.Split(m.Option(ice.DEV)) {
|
||||
m.Cmd(SPACE, tcp.DIAL, ice.DEV, v, mdb.NAME, ice.Info.NodeName)
|
||||
}
|
||||
@ -110,15 +110,12 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
||||
Render(m, m.Option(ice.MSG_OUTPUT), m.Optionv(ice.MSG_ARGS))
|
||||
}
|
||||
func _serve_domain(m *ice.Message) string {
|
||||
return kit.GetValid(func() string {
|
||||
return ice.Info.Domain
|
||||
}, func() string {
|
||||
return m.R.Header.Get("X-Host")
|
||||
}, func() string {
|
||||
return kit.Select("", m.R.Header.Get(Referer), m.R.Method == SPIDE_POST)
|
||||
}, func() string {
|
||||
return kit.Format("%s://%s", kit.Select("https", ice.HTTP, m.R.TLS == nil), m.R.Host)
|
||||
})
|
||||
return kit.GetValid(
|
||||
func() string { return ice.Info.Domain },
|
||||
func() string { return m.R.Header.Get("X-Host") },
|
||||
func() string { return kit.Select("", m.R.Header.Get(Referer), m.R.Method == SPIDE_POST) },
|
||||
func() string { return kit.Format("%s://%s", kit.Select("https", ice.HTTP, m.R.TLS == nil), m.R.Host) },
|
||||
)
|
||||
}
|
||||
func _serve_login(m *ice.Message, key string, cmds []string, w http.ResponseWriter, r *http.Request) ([]string, bool) {
|
||||
if aaa.SessCheck(m, m.Option(ice.MSG_SESSID)); m.Option(ice.MSG_USERNAME) == "" {
|
||||
@ -155,6 +152,7 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SERVE: {Name: "serve name auto start", Help: "服务器", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Conf("", mdb.HASH, "")
|
||||
cli.NodeInfo(m, ice.Info.PathName, WORKER)
|
||||
aaa.White(m, LOGIN)
|
||||
}},
|
||||
@ -162,9 +160,7 @@ func init() {
|
||||
_serve_start(m)
|
||||
}},
|
||||
SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Go(func() {
|
||||
m.Sleep("30ms", ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, m.Cmdx(SPACE, DOMAIN))+ice.NL)).Cmd(ssh.PROMPT)
|
||||
})
|
||||
m.Sleep("30ms", ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, m.Cmdx(SPACE, DOMAIN))+ice.NL))
|
||||
}},
|
||||
SERVE_REWRITE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] != SPIDE_GET {
|
||||
@ -183,8 +179,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
}},
|
||||
SERVE_PARSE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
}},
|
||||
SERVE_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.MSG_USERNAME) == "" && m.Config(tcp.LOCALHOST) == ice.TRUE && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
aaa.UserRoot(m)
|
||||
|
@ -27,24 +27,45 @@ func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
||||
redial, _ := m.Configv(REDIAL).(ice.Map)
|
||||
a, b, c := kit.Int(redial["a"]), kit.Int(redial["b"]), kit.Int(redial["c"])
|
||||
for i := 0; i >= 0 && i < c; i++ {
|
||||
msg := m.Spawn()
|
||||
msg.Cmd(tcp.CLIENT, tcp.DIAL, args, func(s net.Conn) {
|
||||
if s, _, e := websocket.NewClient(s, uri, nil, kit.Int(redial["r"]), kit.Int(redial["w"])); !msg.Warn(e) {
|
||||
msg.Logs(mdb.CREATE, SPACE, dev, "retry", i, "uri", uri.String())
|
||||
mdb.HashCreate(msg, kit.SimpleKV("", MASTER, dev, host), kit.Dict(mdb.TARGET, s))
|
||||
defer mdb.HashRemove(msg, mdb.NAME, name)
|
||||
if i = 0; _space_handle(msg, true, m.Target().Server().(*Frame), s, dev) {
|
||||
next := time.Duration(rand.Intn(a*(i+1))+b*i) * time.Millisecond
|
||||
m.Cmd(tcp.CLIENT, tcp.DIAL, args, func(c net.Conn) {
|
||||
if conn, _, e := websocket.NewClient(c, uri, nil, kit.Int(redial["r"]), kit.Int(redial["w"])); !m.Warn(e) {
|
||||
mdb.HashCreate(m, kit.SimpleKV("", MASTER, dev, host), kit.Dict(mdb.TARGET, conn))
|
||||
defer mdb.HashRemove(m, mdb.NAME, name)
|
||||
if i = 0; _space_handle(m, true, dev, conn, m.Target().Server().(*Frame)) {
|
||||
i = -2
|
||||
}
|
||||
}
|
||||
})
|
||||
sleep := time.Duration(rand.Intn(a*(i+1))+b) * time.Millisecond
|
||||
msg.Cost("order", i, "sleep", sleep, "redial", dev)
|
||||
time.Sleep(sleep)
|
||||
}).Cost("order", i, "sleep", next, "redial", dev).Sleep(next)
|
||||
}
|
||||
})
|
||||
}
|
||||
func _space_handle(m *ice.Message, safe bool, f *Frame, conn *websocket.Conn, name string) bool {
|
||||
func _space_fork(m *ice.Message) {
|
||||
buffer, _ := m.Configv(BUFFER).(ice.Map)
|
||||
if conn, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(buffer["r"]), kit.Int(buffer["w"])); m.Assert(e) {
|
||||
text := kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.TEXT))
|
||||
name := strings.ToLower(kit.ReplaceAll(kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.NAME)), ice.PT, "_", ice.DF, "_"))
|
||||
args := append([]string{mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text}, m.OptionSimple(SHARE, RIVER, ice.MSG_USERUA)...)
|
||||
m.Go(func() {
|
||||
mdb.HashCreate(m, args, kit.Dict(mdb.TARGET, conn))
|
||||
defer mdb.HashRemove(m, m.OptionSimple(mdb.NAME))
|
||||
gdb.Event(m, SPACE_OPEN, args)
|
||||
defer gdb.Event(m, SPACE_CLOSE, args)
|
||||
switch m.Option(mdb.TYPE) {
|
||||
case CHROME:
|
||||
m.Cmd(SPACE, name, cli.PWD, name)
|
||||
case WORKER:
|
||||
gdb.Event(m, DREAM_START, args)
|
||||
defer gdb.Event(m, DREAM_STOP, args)
|
||||
if m.Option(cli.DAEMON) == ice.OPS {
|
||||
defer m.Cmd(DREAM, DREAM_STOP, args)
|
||||
}
|
||||
}
|
||||
_space_handle(m, false, name, conn, m.Target().Server().(*Frame))
|
||||
})
|
||||
}
|
||||
}
|
||||
func _space_handle(m *ice.Message, safe bool, name string, conn *websocket.Conn, f *Frame) bool {
|
||||
for {
|
||||
_, b, e := conn.ReadMessage()
|
||||
if m.Warn(e, SPACE, name) {
|
||||
@ -66,6 +87,7 @@ func _space_handle(m *ice.Message, safe bool, f *Frame, conn *websocket.Conn, na
|
||||
}
|
||||
}) {
|
||||
} else if res, ok := f.getSend(msg.Option(ice.MSG_TARGET)); !m.Warn(!ok || len(target) != 1) {
|
||||
res.Cost(kit.Format("[%v]->%v %v %v", f.delSend(res.Option(ice.MSG_SOURCE)), res.Option(ice.MSG_TARGET), res.Detailv(), msg.FormatSize()))
|
||||
back(res, msg) // 接收响应
|
||||
}
|
||||
}
|
||||
@ -74,34 +96,29 @@ func _space_handle(m *ice.Message, safe bool, f *Frame, conn *websocket.Conn, na
|
||||
func _space_domain(m *ice.Message) (link string) {
|
||||
return kit.GetValid(
|
||||
func() string { return ice.Info.Domain },
|
||||
func() string {
|
||||
return m.CmdAppend(SPACE, ice.OPS, cli.PWD, kit.Dict(ice.MSG_OPTS, ice.MSG_USERNAME), mdb.LINK)
|
||||
},
|
||||
func() string { return m.CmdAppend(SPACE, ice.OPS, cli.PWD, kit.Dict(ice.MSG_OPTS, ice.MSG_USERNAME), mdb.LINK) },
|
||||
func() string { return m.CmdAppend(SPACE, ice.DEV, cli.PWD, mdb.LINK) },
|
||||
func() string { return m.CmdAppend(SPACE, ice.SHY, cli.PWD, mdb.LINK) },
|
||||
func() string { return tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)) },
|
||||
func() string {
|
||||
return kit.Format("http://%s:%s", m.CmdAppend(tcp.HOST, aaa.IP), kit.Select(m.Option(tcp.PORT), m.CmdAppend(SERVE, tcp.PORT)))
|
||||
})
|
||||
func() string { return kit.Format("http://%s:%s", m.CmdAppend(tcp.HOST, aaa.IP), kit.Select(m.Option(tcp.PORT), m.CmdAppend(SERVE, tcp.PORT))) })
|
||||
}
|
||||
func _space_exec(msg *ice.Message, source, target []string, conn *websocket.Conn) {
|
||||
switch kit.Select(msg.Detailv(), 0) {
|
||||
case "pwd":
|
||||
switch kit.Select(cli.PWD, msg.Detailv(), 0) {
|
||||
case cli.PWD:
|
||||
msg.Push(mdb.LINK, kit.MergePOD(_space_domain(msg), kit.Select("", source, -1)))
|
||||
default:
|
||||
if aaa.Right(msg, msg.Detailv()) {
|
||||
msg = msg.Cmd()
|
||||
}
|
||||
}
|
||||
defer msg.Cost(kit.Format("%v->%v %v %v", source, target, msg.Detailv(), msg.FormatSize()))
|
||||
_space_echo(msg.Set(ice.MSG_OPTS), []string{}, kit.Revert(kit.Simple(source)), conn)
|
||||
msg.Cost(kit.Format("%v->%v %v %v", source, target, msg.Detailv(), msg.FormatSize()))
|
||||
}
|
||||
func _space_echo(msg *ice.Message, source, target []string, conn *websocket.Conn) {
|
||||
if msg.Optionv(ice.MSG_SOURCE, source, ice.MSG_TARGET, target[1:]); msg.Warn(conn.WriteMessage(1, []byte(msg.FormatMeta()))) {
|
||||
msg.Go(func() { mdb.HashRemove(msg, mdb.NAME, target[0]) })
|
||||
conn.Close()
|
||||
func _space_echo(m *ice.Message, source, target []string, conn *websocket.Conn) {
|
||||
if m.Options(ice.MSG_SOURCE, source, ice.MSG_TARGET, target[1:]); m.Warn(conn.WriteMessage(1, []byte(m.FormatMeta()))) {
|
||||
mdb.HashRemove(m, mdb.NAME, target[0])
|
||||
} else {
|
||||
msg.Log("send", "%v->%v %v %v", source, target, msg.Detailv(), msg.FormatMeta())
|
||||
m.Log("send", "%v->%v %v %v", source, target, m.Detailv(), m.FormatMeta())
|
||||
}
|
||||
}
|
||||
func _space_send(m *ice.Message, space string, arg ...string) {
|
||||
@ -116,46 +133,14 @@ func _space_send(m *ice.Message, space string, arg ...string) {
|
||||
m.Optionv(k, m.Optionv(k))
|
||||
}
|
||||
})
|
||||
m.Set(ice.MSG_DETAIL, arg...)
|
||||
m.Optionv(ice.MSG_OPTS, m.Optionv(ice.MSG_OPTS))
|
||||
m.Optionv(ice.MSG_OPTION, m.Optionv(ice.MSG_OPTS))
|
||||
target, id, f := kit.Split(space, ice.PT, ice.PT), "", m.Target().Server().(*Frame)
|
||||
if m.Warn(!mdb.HashSelectDetail(m, target[0], func(value ice.Map) {
|
||||
if conn, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotFound, mdb.TARGET) {
|
||||
id = f.addSend(kit.Format(m.Target().ID()), m)
|
||||
_space_echo(m, []string{id}, target, conn)
|
||||
m.Set(ice.MSG_DETAIL, arg...).Optionv(ice.MSG_OPTION, m.Optionv(ice.MSG_OPTS, m.Optionv(ice.MSG_OPTS)))
|
||||
target, f := kit.Split(space, ice.PT, ice.PT), m.Target().Server().(*Frame)
|
||||
if !m.Warn(!mdb.HashSelectDetail(m, target[0], func(value ice.Map) {
|
||||
if conn, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, mdb.TARGET) {
|
||||
_space_echo(m, []string{f.addSend(kit.Format(m.Target().ID()), m)}, target, conn)
|
||||
}
|
||||
}), ice.ErrNotFound, space) {
|
||||
return
|
||||
}
|
||||
call(m, m.Config(kit.Keys(TIMEOUT, "c")), func(res *ice.Message) {
|
||||
m.Cost(kit.Format("[%v]->%v %v %v", f.delSend(id), target, arg, m.Copy(res).FormatSize()))
|
||||
})
|
||||
}
|
||||
func _space_fork(m *ice.Message) {
|
||||
buffer, _ := m.Configv(BUFFER).(ice.Map)
|
||||
if s, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(buffer["r"]), kit.Int(buffer["w"])); m.Assert(e) {
|
||||
text := kit.Select(s.RemoteAddr().String(), m.Option(ice.MSG_USERADDR))
|
||||
name := strings.ToLower(m.Option(mdb.NAME, kit.ReplaceAll(kit.Select(text, m.Option(mdb.NAME)), ice.PT, "_", ice.DF, "_")))
|
||||
kind := kit.Select(WORKER, m.Option(mdb.TYPE))
|
||||
args := append([]string{mdb.TYPE, kind, mdb.NAME, name}, m.OptionSimple(SHARE, RIVER, ice.MSG_USERUA)...)
|
||||
m.Go(func() {
|
||||
mdb.HashCreate(m, mdb.TEXT, kit.Select(text, m.Option(mdb.TEXT)), args, kit.Dict(mdb.TARGET, s))
|
||||
defer mdb.HashRemove(m, mdb.NAME, name)
|
||||
gdb.Event(m, SPACE_OPEN, args)
|
||||
defer gdb.Event(m, SPACE_CLOSE, args)
|
||||
switch kind {
|
||||
case CHROME:
|
||||
m.Go(func(msg *ice.Message) { msg.Sleep30ms(SPACE, name, cli.PWD, name) })
|
||||
case WORKER:
|
||||
gdb.Event(m, DREAM_START, args)
|
||||
defer gdb.Event(m, DREAM_STOP, args)
|
||||
if m.Option(cli.DAEMON) == ice.OPS {
|
||||
defer m.Cmd(DREAM, DREAM_STOP, args)
|
||||
}
|
||||
}
|
||||
_space_handle(m, false, m.Target().Server().(*Frame), s, name)
|
||||
})
|
||||
call(m, m.Config(kit.Keys(TIMEOUT, "c")), func(res *ice.Message) { m.Copy(res) })
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +169,6 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PP(SPACE): {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
||||
SPACE: {Name: "space name cmd auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", mdb.HASH, "") }},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", mdb.HASH, "") }},
|
||||
tcp.DIAL: {Name: "dial dev=ops name", Hand: func(m *ice.Message, arg ...string) {
|
||||
if strings.HasPrefix(m.Option(ice.DEV), ice.HTTP) {
|
||||
@ -199,9 +183,10 @@ func init() {
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT)
|
||||
}},
|
||||
SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(ice.MSG_USERROLE, kit.Select(m.Option(ice.MSG_USERROLE), m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.USERROLE)))
|
||||
if m.Option(ice.MSG_USERROLE) == aaa.VOID && ice.Info.UserName == aaa.VOID {
|
||||
if ice.Info.UserName == aaa.VOID {
|
||||
m.Option(ice.MSG_USERROLE, aaa.TECH)
|
||||
} else {
|
||||
m.Option(ice.MSG_USERROLE, kit.Select(m.Option(ice.MSG_USERROLE), m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.USERROLE)))
|
||||
}
|
||||
m.Auth(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
||||
}},
|
||||
@ -220,10 +205,10 @@ func init() {
|
||||
ProcessWebsite(m, m.Option(mdb.NAME), m.PrefixKey())
|
||||
}
|
||||
}},
|
||||
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
|
||||
OPEN: {Hand: func(m *ice.Message, arg ...string) { ProcessIframe(m, MergePod(m, m.Option(mdb.NAME)), arg...) }},
|
||||
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text",
|
||||
REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "180s"),
|
||||
REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "30s"),
|
||||
BUFFER, kit.Dict("r", ice.MOD_BUFS, "w", ice.MOD_BUFS),
|
||||
), SpaceAction(), DreamAction(), ctx.CmdAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
||||
@ -249,16 +234,9 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
var spaceActions = kit.DictList(SPACE_START, SPACE_OPEN, SPACE_LOGIN, SPACE_CLOSE, SPACE_STOP)
|
||||
|
||||
func SpaceAction() ice.Actions {
|
||||
return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
for sub := range m.Target().Commands[m.CommandKey()].Actions {
|
||||
if spaceActions[sub] == ice.TRUE {
|
||||
gdb.Watch(m, sub)
|
||||
}
|
||||
}
|
||||
}}}
|
||||
return gdb.EventsAction(SPACE_START, SPACE_OPEN, SPACE_LOGIN, SPACE_CLOSE, SPACE_STOP)
|
||||
}
|
||||
func Space(m *ice.Message, arg ice.Any) []string {
|
||||
if arg == nil || arg == "" || kit.Format(arg) == ice.Info.NodeName {
|
||||
@ -266,25 +244,26 @@ func Space(m *ice.Message, arg ice.Any) []string {
|
||||
}
|
||||
return []string{SPACE, kit.Format(arg)}
|
||||
}
|
||||
|
||||
func call(m *ice.Message, timeout string, cb func(*ice.Message)) {
|
||||
func call(m *ice.Message, timeout string, cb func(*ice.Message)) bool {
|
||||
wait := make(chan bool, 2)
|
||||
t := time.AfterFunc(kit.Duration(timeout), func() {
|
||||
m.Warn(true, ice.ErrNotValid, m.Detailv())
|
||||
cb(nil)
|
||||
m.Optionv("_cb", nil)
|
||||
cb(nil)
|
||||
wait <- false
|
||||
})
|
||||
m.Optionv("_cb", func(res *ice.Message) {
|
||||
cb(res)
|
||||
t.Stop()
|
||||
cb(res)
|
||||
wait <- true
|
||||
})
|
||||
<-wait
|
||||
return <-wait
|
||||
}
|
||||
func back(m *ice.Message, res *ice.Message) {
|
||||
func back(m *ice.Message, res *ice.Message) bool {
|
||||
switch cb := m.Optionv("_cb").(type) {
|
||||
case func(*ice.Message):
|
||||
cb(res)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user