Documentation
¶
Index ¶
- func HTMLHandlego(w http.ResponseWriter, req *http.Request)
- func NullHandle(w http.ResponseWriter, req *http.Request)
- func TimeoutRun(et event.JsonMap, w http.ResponseWriter)
- func WebSocketHTMLHandlego(w http.ResponseWriter, req *http.Request)
- type DataThread
- type HTTPConfig
- type HTTPModule
- type IModule
- type LogicConfig
- type LogicModule
- type LogicThreadModule
- type MemoryConfig
- type MemoryModule
- func (this *MemoryModule) AddListenMsg(data event.IMemoryModel)
- func (this *MemoryModule) DelListenMsg(data event.IMemoryModel)
- func (this *MemoryModule) GetNum() int
- func (this *MemoryModule) Handle(ctx context.Context)
- func (this *MemoryModule) Init()
- func (this *MemoryModule) PrintStatus() string
- func (this *MemoryModule) Start()
- func (this *MemoryModule) Stop()
- type MemoryThread
- type NsqdConfig
- type NsqdModule
- func (this *NsqdModule) AddMsg(msg event.INsqdMessage) bool
- func (this *NsqdModule) AddMsgSync(msg event.INsqdMessage) error
- func (this *NsqdModule) Handle(ctx context.Context)
- func (this *NsqdModule) HandleMessage(message *nsq.Message) (err error)
- func (this *NsqdModule) Init()
- func (this *NsqdModule) PingNsq(ctx context.Context) bool
- func (this *NsqdModule) PrintStatus() string
- func (this *NsqdModule) Start()
- func (this *NsqdModule) Stop()
- func (this *NsqdModule) StopConsumer()
- type SocketClientModule
- type SocketModule
- type SqlDataConfig
- type SqlDataModule
- type WebSocketConfig
- type WebSocketModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTMLHandlego ¶
func HTMLHandlego(w http.ResponseWriter, req *http.Request)
HTMLHandlego 默认的所有没定义的处理请求
func NullHandle ¶
func NullHandle(w http.ResponseWriter, req *http.Request)
NullHandle 默认的所有没定义的处理请求
func WebSocketHTMLHandlego ¶
func WebSocketHTMLHandlego(w http.ResponseWriter, req *http.Request)
WebSocketHTMLHandlego 默认的所有没定义的处理请求
Types ¶
type DataThread ¶
type DataThread struct {
KeyID int //用户主键
SendChan chan []event.ISqlDataModel //收要更新的数据
Conndb *sql.DB //数据库连接对象
UpTime time.Time //更新时间
TranSave bool //是否用事务做保存
// contains filtered or unexported fields
}
DataThread 用户的数据库协程
func (*DataThread) CloseChan ¶
func (this *DataThread) CloseChan()
func (*DataThread) Handle ¶
func (this *DataThread) Handle(ctx context.Context, mg *SqlDataModule)
Handle 保存数据的协程
func (*DataThread) Start ¶
func (this *DataThread) Start(mg *SqlDataModule)
func (*DataThread) Stop ¶
func (this *DataThread) Stop(mg *SqlDataModule, index int)
type HTTPConfig ¶
HTTPConfig httpmodule的配置
type HTTPModule ¶
type HTTPModule struct {
HTTPAddr string //HTTP监听的地址
RouteFun func(code int) event.HTTPcall //用来生成事件处理器的工厂
TimeoutFun event.HTTPcall //超时时的回调方法
GetIPFun func(w http.ResponseWriter, req *http.Request) string //拿IP的方法
// contains filtered or unexported fields
}
HTTPModule ... http连接模块
func NewHTTPModule ¶
func NewHTTPModule(configmd *HTTPConfig) *HTTPModule
NewHTTPModule 生成一个新的HTTP的对象
func (*HTTPModule) Handle ¶
func (mod *HTTPModule) Handle(w http.ResponseWriter, req *http.Request)
Handle http发来的所有请求都会到这个方法来
func (*HTTPModule) PrintStatus ¶
func (mod *HTTPModule) PrintStatus() string
PrintStatus IModule 接口实现,打印状态
type IModule ¶
type IModule interface {
//Init 初始化
Init()
//Start 启动
Start()
//Stop 停止
Stop()
//PrintStatus 打印状态
PrintStatus() string
}
IModule 模块接口
type LogicConfig ¶
type LogicModule ¶
type LogicModule struct {
// contains filtered or unexported fields
}
LogicModule 逻辑模块
func NewLogicModule ¶
func NewLogicModule(config *LogicConfig) *LogicModule
func (*LogicModule) AddMsg ¶
func (this *LogicModule) AddMsg(logicmd event.LogicModel)
AddMsg 发消息给逻辑协程处理
func (*LogicModule) Handle ¶ added in v1.2.3
func (this *LogicModule) Handle(ctx context.Context)
func (*LogicModule) Init ¶
func (this *LogicModule) Init()
func (*LogicModule) PrintStatus ¶
func (mod *LogicModule) PrintStatus() string
PrintStatus IModule 接口实现,打印状态
func (*LogicModule) Start ¶
func (this *LogicModule) Start()
func (*LogicModule) Stop ¶
func (this *LogicModule) Stop()
type LogicThreadModule ¶
type LogicThreadModule struct {
KeyID string //协程key
UpTime time.Time //更新时间
// contains filtered or unexported fields
}
LogicThreadModule 逻辑协程
func (*LogicThreadModule) CloseChan ¶
func (this *LogicThreadModule) CloseChan()
func (*LogicThreadModule) Handle ¶
func (this *LogicThreadModule) Handle(ctx context.Context, mg *LogicModule)
func (*LogicThreadModule) Start ¶
func (this *LogicThreadModule) Start(mg *LogicModule)
func (*LogicThreadModule) Stop ¶
func (this *LogicThreadModule) Stop(mg *LogicModule, index int)
type MemoryConfig ¶
type MemoryConfig struct {
RunTime int //空闲时间(秒)当这个数据这么长时间 没有被访问时就可以运行了
InitNum int //初始化内存空间
ChanNum int //通道缓存空间
}
MemoryConfig 内存模块配置
type MemoryModule ¶
type MemoryModule struct {
// contains filtered or unexported fields
}
MemoryModule 内存缓存管理器
func NewMemoryModule ¶
func NewMemoryModule(config *MemoryConfig) *MemoryModule
func (*MemoryModule) AddListenMsg ¶
func (this *MemoryModule) AddListenMsg(data event.IMemoryModel)
func (*MemoryModule) DelListenMsg ¶
func (this *MemoryModule) DelListenMsg(data event.IMemoryModel)
用来主动关掉服务的方法,关掉了服务找到的关服务器的逻辑,所以不会调用UnloadRun
func (*MemoryModule) Handle ¶
func (this *MemoryModule) Handle(ctx context.Context)
type MemoryThread ¶
type MemoryThread struct {
Key string //主键
DataMemory event.IMemoryModel
// contains filtered or unexported fields
}
func (*MemoryThread) Handle ¶
func (this *MemoryThread) Handle(ctx context.Context, mg *MemoryModule)
type NsqdConfig ¶
type NsqdModule ¶
type NsqdModule struct {
ServerID string //服务器
RouteFun event.NsqdHander
GetNewMsg func() event.INsqdMessage //拿到消息接口对象
// contains filtered or unexported fields
}
func NewNsqdModule ¶
func NewNsqdModule(configmd *NsqdConfig, sid int) *NsqdModule
func (*NsqdModule) AddMsg ¶
func (this *NsqdModule) AddMsg(msg event.INsqdMessage) bool
AddMsg 发送消息出去
func (*NsqdModule) AddMsgSync ¶
func (this *NsqdModule) AddMsgSync(msg event.INsqdMessage) error
AddMsgSync 同步发消息出去
func (*NsqdModule) Handle ¶
func (this *NsqdModule) Handle(ctx context.Context)
func (*NsqdModule) HandleMessage ¶
func (this *NsqdModule) HandleMessage(message *nsq.Message) (err error)
nsq.Handler的接口
func (*NsqdModule) StopConsumer ¶
func (this *NsqdModule) StopConsumer()
StopConsumer如果要关服,需要提前关闭收消息
type SqlDataConfig ¶
type SqlDataModule ¶
type SqlDataModule struct {
// contains filtered or unexported fields
}
SqlDataModule 数据库的模块
func NewSqlDataModule ¶
func NewSqlDataModule(config *SqlDataConfig, sqldb *sql.DB) *SqlDataModule
func (*SqlDataModule) AddMsg ¶
func (this *SqlDataModule) AddMsg(msg ...event.ISqlDataModel)
func (*SqlDataModule) Handle ¶
func (this *SqlDataModule) Handle(ctx context.Context)
func (*SqlDataModule) Init ¶
func (this *SqlDataModule) Init()
func (*SqlDataModule) PrintStatus ¶
func (this *SqlDataModule) PrintStatus() string
PrintStatus 打印状态
func (*SqlDataModule) Start ¶
func (this *SqlDataModule) Start()
func (*SqlDataModule) Stop ¶
func (this *SqlDataModule) Stop()
type WebSocketConfig ¶
type WebSocketConfig struct {
Addr string //websocket 监听地址
Timeout int //超时时间 (秒)
MsgMaxLen int //一个消息最大长度B
}
WebSocketConfig websocket的配置
type WebSocketModule ¶
type WebSocketModule struct {
Addr string //HTTP监听的地址
RouteFun func(code int) event.WebSocketCall //用来生成事件处理器的工厂
WebSocketOnlineFun func(conn *websocket.Conn) string //连接成功后
// contains filtered or unexported fields
}
WebSocketModule socket监听模块
func NewWSModule ¶
func NewWSModule(configmd *WebSocketConfig) *WebSocketModule
NewWSModule 生成一个新的websocket的对象
func (*WebSocketModule) GetPlayerNum ¶
func (mod *WebSocketModule) GetPlayerNum() int
GetPlayerNum用户连接数量
func (*WebSocketModule) Handle ¶
func (mod *WebSocketModule) Handle(conn *websocket.Conn)
Handle http发来的所有请求都会到这个方法来
func (*WebSocketModule) PrintStatus ¶
func (mod *WebSocketModule) PrintStatus() string
PrintStatus IModule 接口实现,打印状态