Documentation ¶
Index ¶
- func DataBaseSetChanNum(channum int) options
- func DataBaseSetTimeout(timeout time.Duration) options
- func GameServiceSetPTime(ptime time.Duration) servOptions
- func GameServiceSetSID(sid int) servOptions
- func GameServiceSetStopHander(handle func()) servOptions
- func LogicSetChanNum(channum int) options
- func LogicSetTimeout(timeout time.Duration) options
- func NsqdSetChanNum(channum int) options
- func NsqdSetLookup(ports ...string) options
- func NsqdSetMaxInFlight(v int) options
- func NsqdSetMyChannelName(name string) options
- func NsqdSetMyTopic(topic string) options
- func NsqdSetPollInterval(t time.Duration) options
- func NsqdSetPorts(ports ...string) options
- func NsqdSetRoute(route messages.IMessageHandle) options
- func SocketCliSetConnName(name string) options
- func SocketCliSetPort(ipport string) options
- func SocketCliSetRoute(route messages.IMessageHandle) options
- func SocketSetPort(ipport string) options
- func SocketSetRoute(route messages.IMessageHandle) options
- func SocketSetTimeout(timeout time.Duration) options
- func WebSetIpPort(ipPort string) options
- func WebSetRoute(route messages.IMessageHandle) options
- func WebSetTimeout(timeout time.Duration) options
- func WebSetTimeoutFunc(...) options
- func WebSocketSetFrame(frame byte) options
- func WebSocketSetIpPort(ipPort string) options
- func WebSocketSetOnlineFun(fun func(conn *messages.WebSocketModel)) options
- func WebSocketSetRoute(route messages.IMessageHandle) options
- func WebSocketSetTimeout(timeout time.Duration) options
- type AutoTaskModel
- type AutoTaskModule
- func (mod *AutoTaskModule) AddTask(task IAutoTaskModel) bool
- func (mod *AutoTaskModule) DelRask(name string) bool
- func (mod *AutoTaskModule) Init()
- func (mod *AutoTaskModule) PrintStatus() string
- func (mod *AutoTaskModule) ReTask(task IAutoTaskModel) bool
- func (mod *AutoTaskModule) Start()
- func (mod *AutoTaskModule) Stop()
- type DataBaseModule
- type GameService
- type IAutoTaskModel
- type IModule
- type LogicModule
- type NsqdModule
- func (mod *NsqdModule) AddMsg(msg messages.INsqdResultMessage) bool
- func (mod *NsqdModule) AddMsgSync(msg messages.INsqdResultMessage) error
- func (mod *NsqdModule) Handle(ctx context.Context)
- func (mod *NsqdModule) HandleMessage(message *nsq.Message) (err error)
- func (mod *NsqdModule) Init()
- func (mod *NsqdModule) PingNsq(ctx context.Context) bool
- func (mod *NsqdModule) PrintStatus() string
- func (mod *NsqdModule) Start()
- func (mod *NsqdModule) Stop()
- type SocketCliModule
- func (mod *SocketCliModule) AddMsgSyn(msg messages.IMessage) error
- func (mod *SocketCliModule) AddMsgSynByGate(gate messages.IGateMessage, msg interface{}) error
- func (mod *SocketCliModule) Init()
- func (mod *SocketCliModule) PrintStatus() string
- func (mod *SocketCliModule) Start()
- func (mod *SocketCliModule) Stop()
- type SocketModule
- type WebModule
- type WebSocketModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataBaseSetChanNum ¶
func DataBaseSetChanNum(channum int) options
func GameServiceSetPTime ¶
func GameServiceSetSID ¶
func GameServiceSetSID(sid int) servOptions
func GameServiceSetStopHander ¶
func GameServiceSetStopHander(handle func()) servOptions
func SocketCliSetPort ¶
func SocketCliSetPort(ipport string) options
func SocketSetPort ¶
func SocketSetPort(ipport string) options
func SocketSetTimeout ¶
超时时间(秒) 例:超时时间为10秒时,就传入10
func WebSetTimeoutFunc ¶
func WebSetTimeoutFunc(timeoutfunc func(webmsg messages.IHttpMessageHandle, w http.ResponseWriter, req *http.Request)) options
设置超时回调方法
func WebSocketSetFrame ¶ added in v1.2.4
func WebSocketSetFrame(frame byte) options
设置Frame websocket.XXXFrame default websocket.BinaryFrame
func WebSocketSetIpPort ¶
func WebSocketSetIpPort(ipPort string) options
func WebSocketSetOnlineFun ¶ added in v1.2.3
func WebSocketSetOnlineFun(fun func(conn *messages.WebSocketModel)) options
连接成功后回调,可以用来获取一些连接的信息,比如IP
func WebSocketSetTimeout ¶
超时时间(秒) 例:超时时间为10秒时,就传入10
Types ¶
type AutoTaskModel ¶
type AutoTaskModel struct { Handle func(ctx context.Context) //需要实现这个方法 // contains filtered or unexported fields }
func (*AutoTaskModel) GetTaskName ¶
func (task *AutoTaskModel) GetTaskName() string
任务名字(唯一性)需要重载更新这个名字
type AutoTaskModule ¶
type AutoTaskModule struct {
// contains filtered or unexported fields
}
func NewAutoTaskModule ¶
func NewAutoTaskModule(opts ...options) *AutoTaskModule
func (*AutoTaskModule) AddTask ¶
func (mod *AutoTaskModule) AddTask(task IAutoTaskModel) bool
添加新任务,如果任务已存在,就返回false
func (*AutoTaskModule) PrintStatus ¶
func (mod *AutoTaskModule) PrintStatus() string
PrintStatus 打印状态
func (*AutoTaskModule) ReTask ¶
func (mod *AutoTaskModule) ReTask(task IAutoTaskModel) bool
添加新任务,如果任务已存在,就把旧的给关掉
type DataBaseModule ¶
type DataBaseModule struct {
// contains filtered or unexported fields
}
func NewDataBaseModule ¶
func NewDataBaseModule(conndb *sql.DB, opts ...options) *DataBaseModule
func (*DataBaseModule) AddMsg ¶
func (mod *DataBaseModule) AddMsg(msgs ...messages.IDataBaseMessage)
func (*DataBaseModule) Handle ¶
func (mod *DataBaseModule) Handle(ctx context.Context)
func (*DataBaseModule) PrintStatus ¶
func (mod *DataBaseModule) PrintStatus() string
PrintStatus 打印状态
type GameService ¶
type GameService struct { ServiceID int //游戏服务器ID PStatusTime time.Duration //打印状态的时间(秒) ServiceStopHander func() //当服务器被关掉的时候,先调用的方法 ServiceStartHander func() //当服务器所有服务都启动后,先调用的方法 // contains filtered or unexported fields }
func NewGameService ¶
func NewGameService(opts ...servOptions) *GameService
func (*GameService) AddModule ¶
func (gs *GameService) AddModule(mds ...IModule)
AddModule 给这个管理器,加新的模块
func (*GameService) GetIsRun ¶
func (gs *GameService) GetIsRun() bool
GetIsRun 我们游戏是不是还在运行着,如果为false表示我们服务器正在关闭中
type IAutoTaskModel ¶
type IAutoTaskModel interface { //任务名字(唯一性) GetTaskName() string //开始任务 Start(mod *AutoTaskModule) //结束任务 Stop() }
循环任务接口 使用AddTask添加到module中时,如果任务以存在就不做任何事 使用ReTask添加到module中时,如果任务已存在就会先把之前的停下来,再把自己添加到管理器中
type IModule ¶
type IModule interface { //Init 初始化 Init() //Start 启动 Start() //Stop 停止 Stop() //PrintStatus 打印状态 PrintStatus() string }
IModule 模块接口
type LogicModule ¶
type LogicModule struct {
// contains filtered or unexported fields
}
func NewLogicModule ¶
func NewLogicModule(opts ...options) *LogicModule
func (*LogicModule) AddMsg ¶
func (mod *LogicModule) AddMsg(logicmd messages.ILogicMessage)
AddMsg 发消息给逻辑协程处理
func (*LogicModule) Handle ¶ added in v1.2.3
func (mod *LogicModule) Handle(ctx context.Context)
func (*LogicModule) Init ¶
func (mod *LogicModule) Init()
func (*LogicModule) PrintStatus ¶
func (mod *LogicModule) PrintStatus() string
PrintStatus IModule 接口实现,打印状态
func (*LogicModule) Start ¶
func (mod *LogicModule) Start()
func (*LogicModule) Stop ¶
func (mod *LogicModule) Stop()
type NsqdModule ¶
type NsqdModule struct { Topic string //本服务器监听的主题 ChannelName string //本服务器监听的通道名 RouteHandle messages.IMessageHandle //消息路由 // contains filtered or unexported fields }
func NewNsqdModule ¶
func NewNsqdModule(opts ...options) *NsqdModule
func (*NsqdModule) AddMsg ¶
func (mod *NsqdModule) AddMsg(msg messages.INsqdResultMessage) bool
AddMsg 发送消息出去
func (*NsqdModule) AddMsgSync ¶
func (mod *NsqdModule) AddMsgSync(msg messages.INsqdResultMessage) error
AddMsgSync 同步发消息出去
func (*NsqdModule) Handle ¶
func (mod *NsqdModule) Handle(ctx context.Context)
func (*NsqdModule) HandleMessage ¶
func (mod *NsqdModule) HandleMessage(message *nsq.Message) (err error)
nsq.Handler的接口 收nsqd的消息
type SocketCliModule ¶
type SocketCliModule struct { ConInfo interface{} //自定义的连接信息,给上层逻辑使用 ConnName string //连接名字 RouteHandle messages.IMessageHandle //消息路由 // contains filtered or unexported fields }
func NewSocketCliModule ¶
func NewSocketCliModule(opts ...options) *SocketCliModule
func (*SocketCliModule) AddMsgSyn ¶
func (mod *SocketCliModule) AddMsgSyn(msg messages.IMessage) error
同步写入消息
func (*SocketCliModule) AddMsgSynByGate ¶ added in v1.3.0
func (mod *SocketCliModule) AddMsgSynByGate(gate messages.IGateMessage, msg interface{}) error
同步写入网关的消息
func (*SocketCliModule) PrintStatus ¶
func (mod *SocketCliModule) PrintStatus() string
PrintStatus 打印状态
type SocketModule ¶
type SocketModule struct { RouteHandle messages.IMessageHandle //消息路由 // contains filtered or unexported fields }
func NewSocketModule ¶
func NewSocketModule(opts ...options) *SocketModule
type WebModule ¶
type WebModule struct { RouteHandle messages.IMessageHandle //消息路由 // contains filtered or unexported fields }
func NewWebModule ¶
func NewWebModule(opts ...options) *WebModule
type WebSocketModule ¶
type WebSocketModule struct { RouteHandle messages.IMessageHandle //消息路由 // contains filtered or unexported fields }
func NewWebSocketModule ¶
func NewWebSocketModule(opts ...options) *WebSocketModule
func (*WebSocketModule) GetPlayerNum ¶
func (mod *WebSocketModule) GetPlayerNum() int64
GetPlayerNum用户连接数量
func (*WebSocketModule) Handle ¶
func (mod *WebSocketModule) Handle(conn *websocket.Conn)
Handle http发来的所有请求都会到这个方法来
func (*WebSocketModule) PrintStatus ¶
func (mod *WebSocketModule) PrintStatus() string
PrintStatus 打印状态
Click to show internal directories.
Click to hide internal directories.