actor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ASF_NULL = iota
	ASF_RUN  = iota
	ASF_STOP = iota
)
View Source
const (
	DESTROY_EVENT = iota
)

Variables

This section is empty.

Functions

func AssignActorId

func AssignActorId() int64

Types

type ACTOR_TYPE

type ACTOR_TYPE uint32
const (
	ACTOR_TYPE_SINGLETON ACTOR_TYPE = iota //单例
	ACTOR_TYPE_VIRTUAL   ACTOR_TYPE = iota //玩家 必须初始一个全局的actor 作为类型判断
	ACTOR_TYPE_POOL      ACTOR_TYPE = iota //固定数量actor池
	ACTOR_TYPE_STUB      ACTOR_TYPE = iota //stub
)

type Actor

type Actor struct {
	ActorBase
	// contains filtered or unexported fields
}

func (*Actor) GetActorType

func (a *Actor) GetActorType() ACTOR_TYPE

func (*Actor) GetId

func (a *Actor) GetId() int64

func (*Actor) GetName

func (a *Actor) GetName() string

func (*Actor) GetRpcHead

func (a *Actor) GetRpcHead(ctx context.Context) rpc.RpcHead

func (*Actor) GetState

func (a *Actor) GetState() int32

func (*Actor) HasRpc

func (a *Actor) HasRpc(funcName string) bool

func (*Actor) Init

func (a *Actor) Init()

func (*Actor) RegisterTimer

func (a *Actor) RegisterTimer(duration time.Duration, fun func(), opts ...timer.OpOption)

func (*Actor) Send

func (a *Actor) Send(head rpc.RpcHead, packet rpc.Packet)

func (*Actor) SendMsg

func (a *Actor) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})

func (*Actor) SetId

func (a *Actor) SetId(id int64)

func (*Actor) Start

func (a *Actor) Start()

func (*Actor) Stop

func (a *Actor) Stop()

func (*Actor) Trace

func (a *Actor) Trace(funcName string)

func (*Actor) UpdateTimer

func (a *Actor) UpdateTimer(ctx context.Context, ptr uintptr)

type ActorBase

type ActorBase struct {
	Self IActor
	// contains filtered or unexported fields
}

func (*ActorBase) IsActorType

func (a *ActorBase) IsActorType(actorType ACTOR_TYPE) bool

type ActorMgr

type ActorMgr struct {
	// contains filtered or unexported fields
}
var (
	MGR *ActorMgr
)

func (*ActorMgr) Init

func (a *ActorMgr) Init()

func (*ActorMgr) PacketFunc

func (a *ActorMgr) PacketFunc(packet rpc.Packet) bool

func (*ActorMgr) RegisterActor

func (a *ActorMgr) RegisterActor(ac IActor, params ...OpOption)

func (*ActorMgr) SendActor

func (a *ActorMgr) SendActor(funcName string, head rpc.RpcHead, packet rpc.Packet) bool

func (*ActorMgr) SendMsg

func (a *ActorMgr) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})

func (*ActorMgr) Start

func (a *ActorMgr) Start()

type ActorPool

type ActorPool struct {
	MGR IActor
	// contains filtered or unexported fields
}

******************************************************** actorpool管理,不能动态分配 ********************************************************

func (*ActorPool) GetPoolSize

func (a *ActorPool) GetPoolSize() int32

func (*ActorPool) InitPool

func (a *ActorPool) InitPool(pool IActorPool, rType reflect.Type, num int32)

func (*ActorPool) SendActor

func (a *ActorPool) SendActor(head rpc.RpcHead, packet rpc.Packet) bool

type ActorPoolDynamic added in v0.0.9

type ActorPoolDynamic struct {
	MGR IActor
	// contains filtered or unexported fields
}

******************************************************** actorpooldynamic管理, 可以动态添加 ********************************************************

func (*ActorPoolDynamic) AddActor added in v0.0.9

func (a *ActorPoolDynamic) AddActor(ac IActor)

func (*ActorPoolDynamic) DelActor added in v0.0.9

func (a *ActorPoolDynamic) DelActor(Id int64)

func (*ActorPoolDynamic) GetActor added in v0.0.9

func (a *ActorPoolDynamic) GetActor(Id int64) IActor

func (*ActorPoolDynamic) GetActorNum added in v0.0.9

func (a *ActorPoolDynamic) GetActorNum() int

func (*ActorPoolDynamic) GetMgr added in v0.0.9

func (a *ActorPoolDynamic) GetMgr() IActor

func (*ActorPoolDynamic) InitActor added in v0.0.9

func (a *ActorPoolDynamic) InitActor(pPool IActorPool, rType reflect.Type)

func (*ActorPoolDynamic) SendActor added in v0.1.1

func (a *ActorPoolDynamic) SendActor(head rpc.RpcHead, packet rpc.Packet) bool

type CallIO

type CallIO struct {
	rpc.RpcHead
	*rpc.Packet
	Buff []byte
}

type IActor

type IActor interface {
	Init()
	Start()
	Stop()
	SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
	Send(head rpc.RpcHead, packet rpc.Packet)
	RegisterTimer(duration time.Duration, fun func(), opts ...timer.OpOption)
	GetId() int64
	GetState() int32
	GetRpcHead(ctx context.Context) rpc.RpcHead
	GetName() string
	GetActorType() ACTOR_TYPE
	HasRpc(string) bool
	// contains filtered or unexported methods
}

type IActorMgr

type IActorMgr interface {
	Init()
	RegisterActor(ac IActor, params ...OpOption)
	PacketFunc(rpc.Packet) bool
	SendMsg(rpc.RpcHead, string, ...interface{})
}

type IActorPool

type IActorPool interface {
	SendActor(head rpc.RpcHead, packet rpc.Packet) bool
}

******************************************************** actorpool管理,不能动态分配 ********************************************************

type IActorPoolDynamic added in v0.0.9

type IActorPoolDynamic interface {
	GetActor(Id int64) IActor
	AddActor(ac IActor)
	DelActor(Id int64)
	GetActorNum() int
	GetMgr() IActor
}

******************************************************** actorpooldynamic管理, 可以动态添加 ********************************************************

type ICluster

type ICluster interface {
	BindPacketFunc(packetFunc network.PacketFunc)
}

type Op

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

func (*Op) IsActorType

func (op *Op) IsActorType(actorType ACTOR_TYPE) bool

type OpOption

type OpOption func(*Op)

func WithType

func WithType(actor_type ACTOR_TYPE) OpOption

type TraceInfo

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

func (*TraceInfo) Init

func (a *TraceInfo) Init()

func (*TraceInfo) ToString

func (a *TraceInfo) ToString() string

Jump to

Keyboard shortcuts

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