Documentation
¶
Index ¶
- Constants
- func BindSID(agent *Agent)
- func BuildSession(agent *Agent, msg *pmessage.Message) *cproto.Session
- func ClusterLocalDataRoute(agent *Agent, session *cproto.Session, route *pmessage.Route, ...) error
- func Count() int
- func DefaultDataRoute(agent *Agent, route *pmessage.Route, msg *pmessage.Message)
- func ForeachAgent(fn func(a *Agent))
- func GetSID(uid int64) (cfacade.SID, bool)
- func Kick(iActor cfacade.IActor, agentPath, sid string, reason any, closed bool)
- func KickUID(iActor cfacade.IActor, agentPath string, uid cfacade.UID, reason any, ...)
- func LocalDataRoute(agent *Agent, session *cproto.Session, route *pmessage.Route, ...)
- func Push(iActor cfacade.IActor, agentPath, sid string, uid cfacade.UID, route string, ...)
- func PushWithSID(iActor cfacade.IActor, agentPath, sid, route string, v any)
- func PushWithUID(iActor cfacade.IActor, agentPath string, uid cfacade.UID, route string, v any)
- func PushWithUIDS(iActor cfacade.IActor, agentPath string, uidList []int64, allUID bool, ...)
- func Response(iActor cfacade.IActor, agentPath, sid string, mid uint32, v any)
- func ResponseCode(iActor cfacade.IActor, agentPath, sid string, mid uint32, statusCode int32)
- func Unbind(sid cfacade.SID)
- type Actor
- func (p *Actor) AddConnector(connector cfacade.IConnector)
- func (p *Actor) Connectors() []cfacade.IConnector
- func (p *Actor) Load(app cfacade.IApplication)
- func (p *Actor) OnInit()
- func (*Actor) SetDataCompression(compression bool)
- func (*Actor) SetDictionary(dict map[string]uint16)
- func (*Actor) SetHeartbeat(t time.Duration)
- func (*Actor) SetOnDataRoute(fn DataRouteFunc)
- func (p *Actor) SetOnInitFunc(fn func())
- func (p *Actor) SetOnNewAgent(fn OnNewAgentFunc)
- func (*Actor) SetOnPacket(typ ppacket.Type, fn PacketFunc)
- func (*Actor) SetSysData(key string, value interface{})
- func (*Actor) SetWriteBacklog(size int)
- type ActorBase
- func (p *ActorBase) Kick(session *cproto.Session, reason any, closed bool)
- func (p *ActorBase) Push(session *cproto.Session, route string, v any)
- func (p *ActorBase) PushWithUIDS(agentPath string, uidList []int64, allUID bool, route string, v interface{})
- func (p *ActorBase) Response(session *cproto.Session, v any)
- func (p *ActorBase) ResponseCode(session *cproto.Session, statusCode int32)
- type Agent
- func Bind(sid cfacade.SID, uid cfacade.UID) (*Agent, error)
- func GetAgent(sid string, uid cfacade.UID) (*Agent, bool)
- func GetAgentWithSID(sid cfacade.SID) (*Agent, bool)
- func GetAgentWithSIDAndDel(sid cfacade.SID, isDel bool) (*Agent, bool)
- func GetAgentWithUID(uid cfacade.UID) (*Agent, bool)
- func NewAgent(app cfacade.IApplication, conn net.Conn, session *cproto.Session) Agent
- func (a *Agent) AddOnClose(fn OnCloseFunc)
- func (a *Agent) Bind(uid cfacade.UID) (*Agent, error)
- func (a *Agent) Close()
- func (a *Agent) IsBind() bool
- func (a *Agent) Kick(reason interface{}, closed bool)
- func (a *Agent) Push(route string, val interface{})
- func (a *Agent) RemoteAddr() string
- func (a *Agent) Response(session *cproto.Session, v interface{}, isError ...bool)
- func (a *Agent) ResponseCode(session *cproto.Session, statusCode int32, isError ...bool)
- func (a *Agent) ResponseMID(mid uint32, v interface{}, isError ...bool)
- func (a *Agent) Run()
- func (a *Agent) SID() cfacade.SID
- func (a *Agent) SendPacket(typ pomeloPacket.Type, data []byte)
- func (a *Agent) SendRaw(bytes []byte)
- func (a *Agent) Session() *cproto.Session
- func (a *Agent) SetLastAt()
- func (a *Agent) SetState(state int32) bool
- func (a *Agent) State() int32
- func (a *Agent) UID() cfacade.UID
- func (a *Agent) Unbind()
- type Command
- type DataRouteFunc
- type OnCloseFunc
- type OnNewAgentFunc
- type PacketFunc
Constants ¶
View Source
const ( ResponseFuncName = "response" PushFuncName = "push" KickFuncName = "kick" BroadcastName = "broadcast" )
View Source
const ( AgentInit int32 = 0 AgentWaitAck int32 = 1 AgentWorking int32 = 2 AgentClosed int32 = 3 )
View Source
const ( DataHeartbeat = "heartbeat" DataDict = "dict" DataSerializer = "serializer" )
Variables ¶
This section is empty.
Functions ¶
func ClusterLocalDataRoute ¶
func DefaultDataRoute ¶
DefaultDataRoute 默认的消息路由
func ForeachAgent ¶
func ForeachAgent(fn func(a *Agent))
func LocalDataRoute ¶
func PushWithSID ¶
根据sid找到agent,推送消息给客户端
func PushWithUID ¶
根据uid找到agent,推送消息给客户端
func PushWithUIDS ¶
func PushWithUIDS(iActor cfacade.IActor, agentPath string, uidList []int64, allUID bool, route string, v any)
根据uidList或allUID匹配找到Agent,下发数据给客户端
func ResponseCode ¶
根据request的mid找到agent,返回消息给客户端
Types ¶
type Actor ¶
func (*Actor) AddConnector ¶
func (p *Actor) AddConnector(connector cfacade.IConnector)
func (*Actor) Connectors ¶
func (p *Actor) Connectors() []cfacade.IConnector
func (*Actor) Load ¶
func (p *Actor) Load(app cfacade.IApplication)
func (*Actor) SetDataCompression ¶
func (*Actor) SetDictionary ¶
func (*Actor) SetHeartbeat ¶
func (*Actor) SetOnDataRoute ¶
func (*Actor) SetOnDataRoute(fn DataRouteFunc)
func (*Actor) SetOnInitFunc ¶
func (p *Actor) SetOnInitFunc(fn func())
func (*Actor) SetOnNewAgent ¶
func (p *Actor) SetOnNewAgent(fn OnNewAgentFunc)
func (*Actor) SetOnPacket ¶
func (*Actor) SetOnPacket(typ ppacket.Type, fn PacketFunc)
func (*Actor) SetSysData ¶
func (*Actor) SetWriteBacklog ¶
type ActorBase ¶
func (*ActorBase) PushWithUIDS ¶
type Agent ¶
type Agent struct {
cfacade.IApplication // app
// contains filtered or unexported fields
}
func (*Agent) AddOnClose ¶
func (a *Agent) AddOnClose(fn OnCloseFunc)
func (*Agent) RemoteAddr ¶
func (*Agent) ResponseCode ¶
func (*Agent) ResponseMID ¶
func (*Agent) SendPacket ¶
func (a *Agent) SendPacket(typ pomeloPacket.Type, data []byte)
type DataRouteFunc ¶
type OnCloseFunc ¶
type OnCloseFunc func(*Agent)
type OnNewAgentFunc ¶
type OnNewAgentFunc func(newAgent *Agent)
type PacketFunc ¶
Click to show internal directories.
Click to hide internal directories.