event

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataGetByID added in v1.1.5

func DataGetByID(conndb *sql.DB, v IStructSql) *sql.Rows

按接口查询数据

func HTTPReplyMsg

func HTTPReplyMsg(w http.ResponseWriter, et JsonMap, resultcom int, jsdata JsonMap)

HTTPReplyMsg 回复消息

func MarshalQsql added in v1.1.5

func MarshalQsql(v interface{}, tablename string) (sql string)

生成查询SQL

func MarshalUpSql added in v1.1.5

func MarshalUpSql(v interface{}, tablename string) (sql string)

生成更新SQL

func WebSocketReplyMsg

func WebSocketReplyMsg(wsmd *WebSocketModel, et JsonMap, resultcom int, jsdata JsonMap)

WebSocketReplyMsg 回复消息

func WebSocketSendMsg

func WebSocketSendMsg(wsmd *WebSocketModel, action int, jsdata JsonMap)

WebSocketSendMsg 主动给一个用户发消息

Types

type ActorBase

type ActorBase struct {
	EventStepNum int //当前步骤
}

type DataDBModel

type DataDBModel interface {
}

type HTTPcall

type HTTPcall func(et JsonMap, w http.ResponseWriter)

HTTPcall http的调用方法定义

type IActor

type IActor interface {
	//当前要运行的步骤
	GetStepNum() int
	//运行步骤成功就进入下一步,失败就开始执行回滚,成功失败内部处理
	RunNext()
	//是否已完成
	IsEnd() bool
	//拿到要返回用的JSON对象,或不用这个直接推信息
	GetResult() JsonMap
}

IActor 消息盒子的借口

type IMemoryModel

type IMemoryModel interface {
	//放入管理器的KEY
	GetKey() string
	//确认加入到了管理器中后,用来开启,这个数据的一些自动任务
	//如果用这个方法本自来启动任务,就可以用对应的这些方法来关闭自动任务
	RunAutoEvents()
	//时间到时,运行的方法,如果发出了委托,就返回true
	UnloadRun() bool
	//当服务关闭时,运行的方法,这个时候可能就不清内存了,只是关一些自动任务
	DoneRun()
}

IMemoryModel

RunAutoEvents\UnloadRun\DoneRun 这三个方法是在同一个协程上运行的

type IMsgEvent

type IMsgEvent interface {
	GetAction() int    //消息号
	GetActionKey() int //消息序号
	GetMemberID() int  //用户ID
	GetHash() string   //发回给用户信息用的钥匙
}

IMsgEvent 所有的MsgEventBase都要实现这个

type INsqdMessage

type INsqdMessage interface {
	GetSendID() int
	GetSendSID() string
	SetSendSID(sid string)
	GetActionID() int
	GetData() interface{}
	GetTopic() string
}

INsqdMessage 消息接口

func NewNsqdMessage

func NewNsqdMessage(mid, actid int, topic string, data interface{}) INsqdMessage

type ISqlDataModel

type ISqlDataModel interface {
	//用户主键,一般一个用户需要一个专门的协程来负责对他进行保存操作
	//这个ID就是用来确认这件事的
	GetKeyID() int
	//数据表,如果你的表放入时,不是马上保存的,那么后续可以用这个KEY来进行覆盖,
	//这样就可以实现多次修改一次保存的功能
	GetDataKey() string
	//保存时间,每次过来的时候,需要告诉我,你需要最长的保存时间,
	//如果下次保存时间比你的大,那就用你的这个时间 替换掉
	GetUpTime() time.Duration
	//这是被调用的方法
	UpDataSave(conndb model.IConnDB) error
}

ISqlDataModel 保存DB的接口

type IStructSql added in v1.1.5

type IStructSql interface {
	//表名
	GetTableName() string
	//保存参数列表
	ParmArray() []interface{}
	//查询的参数列表
	QueryArray() []interface{}
}

数据映射接口

type JsonArray

type JsonArray []interface{}

JsonArray JSON数组

func (JsonArray) GetArray

func (js JsonArray) GetArray(index int) JsonArray

func (JsonArray) GetIntArray

func (js JsonArray) GetIntArray() []int

func (JsonArray) GetMap

func (js JsonArray) GetMap(index int) JsonMap

type JsonMap

type JsonMap map[string]interface{}

JsonMap 收到的JSON数据

func (JsonMap) GetAction

func (js JsonMap) GetAction() int

GetAction 消息号

func (JsonMap) GetActionKey

func (js JsonMap) GetActionKey() int

GetActionKey int32 //消息序号

func (JsonMap) GetArray

func (js JsonMap) GetArray(key string) JsonArray

返回一个JsonArray

func (JsonMap) GetHash

func (js JsonMap) GetHash() string

GetHash string //发回给用户信息用的钥匙

func (JsonMap) GetIntArray

func (js JsonMap) GetIntArray(key string) []int

返回[]int

func (JsonMap) GetMap

func (js JsonMap) GetMap(key string) JsonMap

返回一个JsonMap

func (JsonMap) GetMemberID

func (js JsonMap) GetMemberID() int

GetMemberID int32 //用户ID

type LogicModel

type LogicModel interface {
	KeyID() string //所在协程的KEY
	Run()          //调用方法
}

LogicModel 逻辑委托

type MemoryMsg

type MemoryMsg struct {
	IMemoryModel
	CmdType int //消息命令类型,1:添加;2:删除;
}

type NsqdHander

type NsqdHander func(msg INsqdMessage)

type NsqdMessage

type NsqdMessage struct {
	SendID   int         //发信息用户ID
	SendSID  string      //发信息服务器(回复用的信息)
	ActionID int         //消息号
	Data     interface{} //消息数据
	Topic    string      //目标
}

func (*NsqdMessage) GetActionID

func (this *NsqdMessage) GetActionID() int

func (*NsqdMessage) GetData

func (this *NsqdMessage) GetData() interface{}

func (*NsqdMessage) GetSendID

func (this *NsqdMessage) GetSendID() int

func (*NsqdMessage) GetSendSID

func (this *NsqdMessage) GetSendSID() string

func (*NsqdMessage) GetTopic

func (this *NsqdMessage) GetTopic() string

func (*NsqdMessage) SetSendSID

func (this *NsqdMessage) SetSendSID(sid string)

type SqlDataModel

type SqlDataModel struct {
	KeyID       int           //用户主键
	DataKey     string        //数据表
	UpTime      time.Duration //保存时间
	SaveFun     UpDataSave    //保存方法
	DataDBModel DataDBModel   //要保存的东西
}

func (*SqlDataModel) GetDataKey

func (this *SqlDataModel) GetDataKey() string

func (*SqlDataModel) GetKeyID

func (this *SqlDataModel) GetKeyID() int

func (*SqlDataModel) GetUpTime

func (this *SqlDataModel) GetUpTime() time.Duration

func (*SqlDataModel) UpDataSave

func (this *SqlDataModel) UpDataSave(conndb model.IConnDB) error

type SqlDataStructModel added in v1.1.5

type SqlDataStructModel struct {
	KeyID       int           //用户主键
	DataKey     string        //数据表
	UpTime      time.Duration //保存时间
	DataDBModel IStructSql    //要保存的东西
}

数据映射接口的导入结构

func (*SqlDataStructModel) GetDataKey added in v1.1.5

func (this *SqlDataStructModel) GetDataKey() string

func (*SqlDataStructModel) GetKeyID added in v1.1.5

func (this *SqlDataStructModel) GetKeyID() int

func (*SqlDataStructModel) GetUpTime added in v1.1.5

func (this *SqlDataStructModel) GetUpTime() time.Duration

func (*SqlDataStructModel) UpDataSave added in v1.1.5

func (this *SqlDataStructModel) UpDataSave(conndb model.IConnDB) error

type UpDataSave

type UpDataSave func(conndb model.IConnDB, datamd DataDBModel) error

type WebSocketCall

type WebSocketCall func(et JsonMap, wsmd *WebSocketModel, runobj *threads.ThreadGo)

WebSocketCall websocket调用方法定义

type WebSocketClose

type WebSocketClose func(wsmd *WebSocketModel)

WebSocketClose 用户连接关闭时的方法

type WebSocketModel

type WebSocketModel struct {
	*websocket.Conn
	CloseFun WebSocketClose //关闭连接时的方法
	ConInfo  interface{}    //自定义的连接信息,给上层逻辑使用
	KeyID    int            //用来标记的ID
}

WebSocketModel 用户连接对象

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL