代码拉取完成,页面将自动刷新
package lua_debugger
import (
"log"
lua "github.com/yuin/gopher-lua"
)
func init() {
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
}
const (
KeyDebuggerFcd = "__Debugger_Fcd"
)
func TcpConnect(L *lua.LState) int {
host := L.CheckString(1)
port := L.CheckNumber(2)
fcd := newFacade()
fcdUd := L.NewUserData()
fcdUd.Value = fcd
L.SetField(L.Get(lua.RegistryIndex), KeyDebuggerFcd, fcdUd)
if err := fcd.TcpConnect(L, host, int(port)); err != nil {
L.Push(lua.LFalse)
L.Push(lua.LString(err.Error()))
return 2
}
L.Push(lua.LTrue)
return 1
}
func TcpClose(L *lua.LState) int {
if fcdUd, ok := L.GetField(L.Get(lua.RegistryIndex), KeyDebuggerFcd).(*lua.LUserData); ok {
if fcd, ok := fcdUd.Value.(*Facade); ok {
if err := fcd.TcpClose(L); err != nil {
L.Push(lua.LString(err.Error()))
return 1
}
}
}
L.Push(lua.LNil)
return 1
}
func SendLogNotify(L *lua.LState, msg string) int {
if fcdUd, ok := L.GetField(L.Get(lua.RegistryIndex), KeyDebuggerFcd).(*lua.LUserData); ok {
if fcd, ok := fcdUd.Value.(*Facade); ok {
fcd.SendLogNotify(msg)
}
}
L.Push(lua.LNil)
return 1
}
var coreApi = map[string]lua.LGFunction{
"tcpConnect": TcpConnect,
"tcpClose": TcpClose,
}
func Loader(L *lua.LState) int {
t := L.NewTable()
L.SetFuncs(t, coreApi)
L.Push(t)
return 1
}
func Preload(L *lua.LState) {
L.PreloadModule("emmy_core", Loader)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。