Documentation ¶
Index ¶
- Constants
- func DecodeAndCheckHeader(s *Server, c gnet.Conn) (cmd uint32, seq uint32, buff []byte, action gnet.Action, pass bool)
- func ErrorField(err error) log.Field
- func ExecuteChain(handlers []TrafficHandler, cmd, seq uint32, buff []byte, c gnet.Conn, ...) (action gnet.Action)
- func FlatMapLog(fields ...[]log.Field) []log.Field
- func NewSession(c gnet.Conn) *session
- func Packet2HexLogStr(pack []byte) log.Field
- func SErrField(err string) log.Field
- func Session(c gnet.Conn) *session
- func Start(s *Server)
- type Direction
- type Operation
- type Server
- func (s *Server) ActiveSessions() int
- func (s *Server) Address() string
- func (s *Server) CountSessionByClientId(clientId string) (counter int)
- func (s *Server) CreateSession(c gnet.Conn) *session
- func (s *Server) Engine() gnet.Engine
- func (s *Server) GoPool() *goroutine.Pool
- func (s *Server) LogCounter() []log.Field
- func (s *Server) LogCounterWithName() []log.Field
- func (s *Server) Name() string
- func (s *Server) OnBoot(eng gnet.Engine) (action gnet.Action)
- func (s *Server) OnClose(c gnet.Conn, e error) (action gnet.Action)
- func (s *Server) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
- func (s *Server) OnShutdown(eng gnet.Engine)
- func (s *Server) OnTick() (delay time.Duration, action gnet.Action)
- func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action)
- func (s *Server) Port() int
- func (s *Server) Protocol() string
- func (s *Server) SessionPool() *sync.Map
- func (s *Server) SessionPoolCap() int
- type TrafficHandler
Constants ¶
View Source
const ( Sid = "sid" // 会话标识 SrvName = "server" // 会话标识 CliName = "auth" // 会话标识 RemoteAddr = "remote" // 发起方地址 LogKeyErr = "error" // 错误信息 LogKeyPacket = "packet" // 数据包 LogKeyPoolFree = "g_session_pool_free" // 【全局】当前会话池剩余量 LogKeyPoolCap = "g_session_pool_cap" // 【全局】会话池最大容量 LogKeyClientConnsCap = "c_conns_cap" // 【会话级】该连接对应的客户端能建立的最大连接数(待采用redis或数据库存储实时会话数,以实现整个集群的连接数可控) LogKeySessionSwCur = "s_sw_cur" // 【会话级】接收消息滑动窗口当前大小 LogKeySessionSwCap = "s_sw_cap" // 【会话级】接收消息滑动窗口最大值 LogKeySessionPoolFree = "s_pool_free" // 【会话级】goroutine goPool 当前使用数 LogKeySessionPoolCap = "s_pool_cap" // 【会话级】goroutine goPool 最大容量 LogKeyCounterMt = "s_mt_num" // 【会话级】下行短信计数 LogKeyCounterDlv = "s_dlv_num" // 【会话级】上行短信计数 LogKeyCounterRpt = "s_rpt_num" // 【会话级】状态报告计数 )
View Source
const ( CMPP = "cmpp" SMGP = "smgp" SGIP = "sgip" )
View Source
const ( StatConnect stat = iota StatLogin StatClosing )
Variables ¶
This section is empty.
Functions ¶
func DecodeAndCheckHeader ¶ added in v0.2.0
func ErrorField ¶
func ExecuteChain ¶
func ExecuteChain(handlers []TrafficHandler, cmd, seq uint32, buff []byte, c gnet.Conn, s *Server) (action gnet.Action)
ExecuteChain all cmppHandlers
func NewSession ¶
func NewSession(c gnet.Conn) *session
func Packet2HexLogStr ¶
Types ¶
type Direction ¶
type Direction string
var RC Direction = "<<<" // 交易请求方向 接收 Remote > Local
var SD Direction = ">>>" // 交易请求方向 发送 Local > Remote
type Server ¶
Server 封装 gnet server
func (*Server) ActiveSessions ¶
func (*Server) CountSessionByClientId ¶
func (*Server) CreateSession ¶
func (s *Server) CreateSession(c gnet.Conn) *session
func (*Server) LogCounter ¶
func (*Server) LogCounterWithName ¶
func (*Server) OnShutdown ¶
func (s *Server) OnShutdown(eng gnet.Engine)
func (*Server) SessionPool ¶
func (*Server) SessionPoolCap ¶
type TrafficHandler ¶
type TrafficHandler func(cmd, seq uint32, buff []byte, c gnet.Conn, s *Server) (next bool, action gnet.Action)
TrafficHandler Don't Read From gnet.Conn. cmd: command id ; seq: request sequence ; buff: packet body ; next: true continue next handler, false return the action
func CmppHandlers ¶ added in v0.2.0
func CmppHandlers() []TrafficHandler
func SgipHandlers ¶ added in v0.2.0
func SgipHandlers() []TrafficHandler
func SmgpHandlers ¶ added in v0.2.0
func SmgpHandlers() []TrafficHandler
Source Files ¶
- chain_cmpp_handler.go
- chain_sgip_handler.go
- chain_smgp_handler.go
- cmpp_active.go
- cmpp_active_resp.go
- cmpp_connect.go
- cmpp_delivery_resp.go
- cmpp_submit.go
- cmpp_terminate.go
- cmpp_terminate_resp.go
- log_utils.go
- on_boot.go
- on_close.go
- on_open.go
- on_shutdown.go
- on_tick.go
- on_traffic.go
- server.go
- session.go
- smgp_active.go
- smgp_active_resp.go
- smgp_delivery_resp.go
- smgp_exit.go
- smgp_exit_resp.go
- smgp_login.go
- smgp_submit.go
Click to show internal directories.
Click to hide internal directories.