pomelo

package
v1.4.19 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 19 Imported by: 7

Documentation

Index

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 BindSID

func BindSID(agent *Agent)

func BuildSession

func BuildSession(agent *Agent, msg *pmessage.Message) *cproto.Session

func ClusterLocalDataRoute

func ClusterLocalDataRoute(agent *Agent, session *cproto.Session, route *pmessage.Route, msg *pmessage.Message, nodeID, targetPath string) error

func Count

func Count() int

func DefaultDataRoute

func DefaultDataRoute(agent *Agent, route *pmessage.Route, msg *pmessage.Message)

DefaultDataRoute 默认的消息路由

func ForeachAgent

func ForeachAgent(fn func(a *Agent))

func GetSID added in v1.4.7

func GetSID(uid int64) (cfacade.SID, bool)

func Kick added in v1.3.1

func Kick(iActor cfacade.IActor, agentPath, sid string, reason any, closed bool)

根据sid找到agent,下发踢除消息给客户端

func KickUID added in v1.4.8

func KickUID(iActor cfacade.IActor, agentPath string, uid cfacade.UID, reason any, closed bool)

func LocalDataRoute

func LocalDataRoute(agent *Agent, session *cproto.Session, route *pmessage.Route, msg *pmessage.Message, targetPath string)

func Push added in v1.3.1

func Push(iActor cfacade.IActor, agentPath, sid string, uid cfacade.UID, route string, v any)

根据sid或uid找到agent,推送消息给客户端

func PushWithSID added in v1.4.3

func PushWithSID(iActor cfacade.IActor, agentPath, sid, route string, v any)

根据sid找到agent,推送消息给客户端

func PushWithUID added in v1.4.3

func PushWithUID(iActor cfacade.IActor, agentPath string, uid cfacade.UID, route string, v any)

根据uid找到agent,推送消息给客户端

func PushWithUIDS added in v1.4.8

func PushWithUIDS(iActor cfacade.IActor, agentPath string, uidList []int64, allUID bool, route string, v any)

根据uidList或allUID匹配找到Agent,下发数据给客户端

func Response added in v1.3.1

func Response(iActor cfacade.IActor, agentPath, sid string, mid uint32, v any)

根据request的mid找到agent,返回消息给客户端

func ResponseCode added in v1.3.1

func ResponseCode(iActor cfacade.IActor, agentPath, sid string, mid uint32, statusCode int32)

根据request的mid找到agent,返回消息给客户端

func Unbind

func Unbind(sid cfacade.SID)

Types

type Actor added in v1.4.7

type Actor struct {
	cactor.Base
	// contains filtered or unexported fields
}

func NewActor

func NewActor(agentActorID string) *Actor

func (*Actor) AddConnector added in v1.4.7

func (p *Actor) AddConnector(connector cfacade.IConnector)

func (*Actor) Connectors added in v1.4.7

func (p *Actor) Connectors() []cfacade.IConnector

func (*Actor) Load added in v1.4.7

func (p *Actor) Load(app cfacade.IApplication)

func (*Actor) OnInit added in v1.4.7

func (p *Actor) OnInit()

OnInit Actor初始化前触发该函数

func (*Actor) SetDataCompression added in v1.4.7

func (*Actor) SetDataCompression(compression bool)

func (*Actor) SetDictionary added in v1.4.7

func (*Actor) SetDictionary(dict map[string]uint16)

func (*Actor) SetHeartbeat added in v1.4.7

func (*Actor) SetHeartbeat(t time.Duration)

func (*Actor) SetOnDataRoute added in v1.4.7

func (*Actor) SetOnDataRoute(fn DataRouteFunc)

func (*Actor) SetOnInitFunc added in v1.4.7

func (p *Actor) SetOnInitFunc(fn func())

func (*Actor) SetOnNewAgent added in v1.4.7

func (p *Actor) SetOnNewAgent(fn OnNewAgentFunc)

func (*Actor) SetOnPacket added in v1.4.7

func (*Actor) SetOnPacket(typ ppacket.Type, fn PacketFunc)

func (*Actor) SetSysData added in v1.4.7

func (*Actor) SetSysData(key string, value interface{})

func (*Actor) SetWriteBacklog added in v1.4.7

func (*Actor) SetWriteBacklog(size int)

type ActorBase

type ActorBase struct {
	cactor.Base
}

func (*ActorBase) Kick

func (p *ActorBase) Kick(session *cproto.Session, reason any, closed bool)

func (*ActorBase) Push

func (p *ActorBase) Push(session *cproto.Session, route string, v any)

func (*ActorBase) PushWithUIDS added in v1.4.8

func (p *ActorBase) PushWithUIDS(agentPath string, uidList []int64, allUID bool, route string, v interface{})

func (*ActorBase) Response

func (p *ActorBase) Response(session *cproto.Session, v any)

func (*ActorBase) ResponseCode

func (p *ActorBase) ResponseCode(session *cproto.Session, statusCode int32)

type Agent

type Agent struct {
	cfacade.IApplication // app
	// contains filtered or unexported fields
}

func Bind added in v1.3.15

func Bind(sid cfacade.SID, uid cfacade.UID) (*Agent, error)

func GetAgent

func GetAgent(sid string, uid cfacade.UID) (*Agent, bool)

func GetAgentWithSID added in v1.4.3

func GetAgentWithSID(sid cfacade.SID) (*Agent, bool)

func GetAgentWithSIDAndDel added in v1.4.7

func GetAgentWithSIDAndDel(sid cfacade.SID, isDel bool) (*Agent, bool)

func GetAgentWithUID

func GetAgentWithUID(uid cfacade.UID) (*Agent, bool)

func NewAgent

func NewAgent(app cfacade.IApplication, conn net.Conn, session *cproto.Session) Agent

func (*Agent) AddOnClose

func (a *Agent) AddOnClose(fn OnCloseFunc)

func (*Agent) Bind

func (a *Agent) Bind(uid cfacade.UID) (*Agent, error)

func (*Agent) Close

func (a *Agent) Close()

func (*Agent) IsBind added in v1.3.4

func (a *Agent) IsBind() bool

func (*Agent) Kick

func (a *Agent) Kick(reason interface{}, closed bool)

func (*Agent) Push

func (a *Agent) Push(route string, val interface{})

func (*Agent) RemoteAddr

func (a *Agent) RemoteAddr() string

func (*Agent) Response

func (a *Agent) Response(session *cproto.Session, v interface{}, isError ...bool)

func (*Agent) ResponseCode

func (a *Agent) ResponseCode(session *cproto.Session, statusCode int32, isError ...bool)

func (*Agent) ResponseMID

func (a *Agent) ResponseMID(mid uint32, v interface{}, isError ...bool)

func (*Agent) Run

func (a *Agent) Run()

func (*Agent) SID

func (a *Agent) SID() cfacade.SID

func (*Agent) SendPacket added in v1.3.6

func (a *Agent) SendPacket(typ pomeloPacket.Type, data []byte)

func (*Agent) SendRaw

func (a *Agent) SendRaw(bytes []byte)

func (*Agent) Session

func (a *Agent) Session() *cproto.Session

func (*Agent) SetLastAt

func (a *Agent) SetLastAt()

func (*Agent) SetState

func (a *Agent) SetState(state int32) bool

func (*Agent) State

func (a *Agent) State() int32

func (*Agent) UID

func (a *Agent) UID() cfacade.UID

func (*Agent) Unbind

func (a *Agent) Unbind()

type Command

type Command struct {
	// contains filtered or unexported fields
}

type DataRouteFunc

type DataRouteFunc func(agent *Agent, route *pmessage.Route, msg *pmessage.Message)

type OnCloseFunc

type OnCloseFunc func(*Agent)

type OnNewAgentFunc

type OnNewAgentFunc func(newAgent *Agent)

type PacketFunc

type PacketFunc func(agent *Agent, packet *ppacket.Packet)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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