Documentation
¶
Index ¶
- func Run(opts *Options, modules ...Module)
- type Agent
- type AgentHook
- type Gate
- type Module
- type Options
- type Skeleton
- func (s *Skeleton) AfterFunc(d time.Duration, cb func()) (timer.TaskID, error)
- func (s *Skeleton) AsynCall(server *chanrpc.Server, id interface{}, args ...interface{})
- func (s *Skeleton) ChanRPCServer() *chanrpc.Server
- func (s *Skeleton) Close()
- func (s *Skeleton) CronFunc(desc string, cb func()) (timer.TaskID, error)
- func (s *Skeleton) Go(f func(), cb func())
- func (s *Skeleton) RegisterChanRPC(id interface{}, f interface{})
- func (s *Skeleton) Run()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Gate ¶
type Gate struct {
MsgMaxLen uint32 // 最大消息长度
MsgMinLen uint32 // 最小消息长度
MaxConnNum int // 最大连接数
WriteBuffer int // 发送消息时的写缓冲区大小
Processor route.Processor // 消息处理
AgentHandler AgentHook // agent handler
// websocket
WSAddr string
CertFile string
KeyFile string
RootCAFile string
HTTPTimeout time.Duration
// tcp
TCPAddr string
MsgHeaderLen int
LittleEndian bool
// contains filtered or unexported fields
}
Gate 基础模块:网关,用于端口监听以及消息转发,一般需要自己实现一个包含本Gate的组合Gate或者直接套用
type Module ¶
type Module interface {
// Init 初始化工作
// 每个模块初始化工作需要做的内容至少包括:
// 1. 注册自己需要被其他模块直接调用的RPC函数
// 2. 给自己模块的消息注册路由
Init()
// Run 运行模块
// 每个模块必须自己Run Skeleton
Run()
// Running 模块是否已经运行起来了
Running() bool
// Destroy 处理模块销毁工作
// 每个模块必须自己Destroy Skeleton
Destroy()
}
type Options ¶
type Options struct {
ServeId uint16 // 服务器ID
// cluster option
ClusterAddr string
ClusterConnAddrs []string
// pprof port
ProfileAddr string
}
Options 服务器选项
type Skeleton ¶
type Skeleton struct {
// contains filtered or unexported fields
}
Skeleton 模块骨架,用于每个模块消息、任务、模块间的调度 每个模块需要包含骨架
func NewSkeleton ¶
func NewSkeleton() *Skeleton
func (*Skeleton) ChanRPCServer ¶
func (*Skeleton) RegisterChanRPC ¶
func (s *Skeleton) RegisterChanRPC(id interface{}, f interface{})
Click to show internal directories.
Click to hide internal directories.