Documentation ¶
Index ¶
- Constants
- func Main_go()
- func OnListenRet(typ string, name string, id int, info string) bool
- func RegLua_all_appBase(L *lua.LState) error
- func RegMsgProc()
- type AppBase
- func (this *AppBase) AddConn(c *ClientConn)
- func (this *AppBase) ConnProc(c *ClientConn, onRet ConnRetFunc)
- func (this *AppBase) ConnProcEx(c *ClientConn, onRet ConnRetFunc)
- func (this *AppBase) Connect(name, net_type, address string, onRet ConnRetFunc)
- func (this *AppBase) DelConn(id int)
- func (this *AppBase) GetConnById(id int) *ClientConn
- func (this *AppBase) GetConnByName(name string) *ClientConn
- func (this *AppBase) GetCurrTime() int64
- func (this *AppBase) GetEvent(name string) help.IEvent
- func (this *AppBase) GetLUserData(n string, a interface{}) *lua.LUserData
- func (this *AppBase) GetLuaState() *lua.LState
- func (this *AppBase) Listen(name, net_type, address string, onRet ConnRetFunc)
- func (this *AppBase) LogBase(level int, info string)
- func (this *AppBase) LogDebug(f string, v ...interface{})
- func (this *AppBase) LogError(f string, v ...interface{})
- func (this *AppBase) LogFatal(f string, v ...interface{})
- func (this *AppBase) LogInfo(f string, v ...interface{})
- func (this *AppBase) LogWarn(f string, v ...interface{})
- func (this *AppBase) MakeLogHeader()
- func (this *AppBase) PostEvent(a help.IEvent) bool
- func (this *AppBase) PostEventFromLua(m string, f string, t uint64, p lua.LValue) bool
- func (this *AppBase) RegMsgFunc(id int, f MsgFunc)
- func (this *AppBase) RemoveEvent(e help.IEvent)
- func (this *AppBase) Start(heart_time int64) bool
- func (this *AppBase) Tolua_Common(m string, f string)
- func (this *AppBase) Tolua_Common_Param(m string, f string, t lua.LValue)
- func (this *AppBase) Tolua_Common_Param_Ret(m string, f string, t lua.LValue) (ret lua.LValue)
- func (this *AppBase) WaitExit()
- type ClientConn
- type ConnRetFunc
- type Event_from_lua
- type ListenConn
- type MsgFunc
- type Msg_node
- type Ty_msg_stream
- func (t *Ty_msg_stream) InitMsgStream(msg *Ty_net_msg)
- func (t *Ty_msg_stream) PrintData()
- func (t *Ty_msg_stream) ReadStr() string
- func (t *Ty_msg_stream) ReadU1() int
- func (t *Ty_msg_stream) ReadU2() int
- func (t *Ty_msg_stream) ReadU4() int
- func (t *Ty_msg_stream) Seek(pos int)
- func (t *Ty_msg_stream) WriteString(d *string) bool
- func (t *Ty_msg_stream) WriteU1(d int) bool
- func (t *Ty_msg_stream) WriteU2(d int) bool
- func (t *Ty_msg_stream) WriteU4(d int) bool
- type Ty_net_msg
Constants ¶
View Source
const ( Evt_gap_time = 16 // 心跳时间(毫秒) Evt_gap_bit = 4 // 心跳时间对应得移位(快速运算使用) Evt_lay1_time = 160000 // 第一层事件池最大支持时间(毫秒) )
View Source
const ( LogDebugLevel = 0 // 日志等级 : 调试信息 LogInfoLevel = 1 // 日志等级 : 普通信息 LogWarnLevel = 2 // 日志等级 : 警告信息 LogErrorLevel = 3 // 日志等级 : 错误信息 LogFatalLevel = 4 // 日志等级 : 致命信息 LogMaxLevel = 5 // 日志最大等级 LogLimitLevel = LogInfoLevel // 显示这个等级之上的日志(控制台) LogBuffMax = 20 * 1024 * 1024 // 日志缓冲 )
View Source
const ( AppName = "login" LogBuffSize = 10 * 1024 * 1024 LogDir = "../log" ProfFile = AppName + "_prof.log" LogFileName = LogDir + "/" + AppName + ".log" )
View Source
const ( MaxDataLen = 5080 MaxSendDataLen = 4000 MaxHeader = 2 )
View Source
const (
UpdateCurrTimeCount = 32 // 刷新时间戳变更上线
)
Variables ¶
This section is empty.
Functions ¶
func RegMsgProc ¶
func RegMsgProc()
Types ¶
type AppBase ¶
type AppBase struct { Listener map[string]*ListenConn // 本地侦听端口 RemoteSvr map[string]*ClientConn // 远程服务连接 Conns map[int]*ClientConn // 连接池 ConnLast int // 最后连接Id MsgProc []MsgFunc // 消息处理函数注册表 MsgProcCount int // 消息函数数量 // contains filtered or unexported fields }
func (*AppBase) AddConn ¶
func (this *AppBase) AddConn(c *ClientConn)
func (*AppBase) ConnProc ¶
func (this *AppBase) ConnProc(c *ClientConn, onRet ConnRetFunc)
func (*AppBase) ConnProcEx ¶
func (this *AppBase) ConnProcEx(c *ClientConn, onRet ConnRetFunc)
func (*AppBase) Connect ¶
func (this *AppBase) Connect(name, net_type, address string, onRet ConnRetFunc)
func (*AppBase) GetConnById ¶
func (this *AppBase) GetConnById(id int) *ClientConn
func (*AppBase) GetConnByName ¶
func (this *AppBase) GetConnByName(name string) *ClientConn
func (*AppBase) GetLUserData ¶
获取用Lua类型封装结构指针 *LUserData
func (*AppBase) GetLuaState ¶
!!!只能获取, 不准许保存指针, 获取LState
func (*AppBase) Listen ¶
func (this *AppBase) Listen(name, net_type, address string, onRet ConnRetFunc)
func (*AppBase) PostEventFromLua ¶
lua投递事件
func (*AppBase) RegMsgFunc ¶
func (*AppBase) RemoveEvent ¶
func (*AppBase) Tolua_Common ¶
调用Lua函数 : 没有参数, 没有返回值
func (*AppBase) Tolua_Common_Param ¶
调用Lua函数 : 只有参数
func (*AppBase) Tolua_Common_Param_Ret ¶
调用Lua函数 : 有参数, 有返回值
type ClientConn ¶
type ClientConn struct { Name string Type string Address string Id int Sid int Msg Ty_net_msg Stream Ty_msg_stream Conn *net.TCPConn }
客户端连接
func (*ClientConn) InitClient ¶
func (c *ClientConn) InitClient(id int, con *net.TCPConn)
func (*ClientConn) IsNull ¶
func (c *ClientConn) IsNull() bool
type Event_from_lua ¶
事件 : lua使用的通用事件
type ListenConn ¶
type ListenConn struct { Name string Type string Address string Conn *net.TCPListener }
侦听服务
func (*ListenConn) InitListen ¶
func (c *ListenConn) InitListen(name, net_type, address string, con *net.TCPListener)
type Msg_node ¶
type Msg_node struct { Len uint32 // 包长度 Token uint32 // 包令牌 Count uint32 // 包内消息数 Data []byte // 数据 }
消息节点(list节点)
type Ty_msg_stream ¶
type Ty_msg_stream struct {
// contains filtered or unexported fields
}
网络消息体读写
func (*Ty_msg_stream) InitMsgStream ¶
func (t *Ty_msg_stream) InitMsgStream(msg *Ty_net_msg)
func (*Ty_msg_stream) PrintData ¶
func (t *Ty_msg_stream) PrintData()
func (*Ty_msg_stream) ReadStr ¶
func (t *Ty_msg_stream) ReadStr() string
func (*Ty_msg_stream) ReadU1 ¶
func (t *Ty_msg_stream) ReadU1() int
func (*Ty_msg_stream) ReadU2 ¶
func (t *Ty_msg_stream) ReadU2() int
func (*Ty_msg_stream) ReadU4 ¶
func (t *Ty_msg_stream) ReadU4() int
func (*Ty_msg_stream) Seek ¶
func (t *Ty_msg_stream) Seek(pos int)
func (*Ty_msg_stream) WriteString ¶
func (t *Ty_msg_stream) WriteString(d *string) bool
func (*Ty_msg_stream) WriteU1 ¶
func (t *Ty_msg_stream) WriteU1(d int) bool
func (*Ty_msg_stream) WriteU2 ¶
func (t *Ty_msg_stream) WriteU2(d int) bool
func (*Ty_msg_stream) WriteU4 ¶
func (t *Ty_msg_stream) WriteU4(d int) bool
type Ty_net_msg ¶
网络消息体
func (*Ty_net_msg) InitNetMsg ¶
func (t *Ty_net_msg) InitNetMsg()
func (*Ty_net_msg) PrintData ¶
func (t *Ty_net_msg) PrintData()
Click to show internal directories.
Click to hide internal directories.