lox

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TimeOut                  = time.Second * 15
	UpdateTime               = time.Second * 15
	LeaseDuration      int64 = 23
	LeaseRenewDuration int64 = 15
)
View Source
const (
	TAG_User = 70
	TAG_JWT  = 71
)
View Source
const REFRESH_TOKEN_EXPIRE_TIME = time.Hour * 24 * 30
View Source
const TOKEN_EXPIRE_TIME = time.Minute * 10

Variables

View Source
var AvatarManagerCtor = avatarManagerCtor{}
View Source
var CenterCtor = centerCtor{}
View Source
var GateCtor = gateCtor{}
View Source
var HttpCtor = httpCtor{}
View Source
var ProxyCtor = proxyCtor{}

Functions

func JwtAuth

func JwtAuth(rsa bool, creator JwtClaimCreator, userCreator UserCreator) func(w rox.ResponseWriter, r *http.Request, a lokas.IProcess, next http.Handler)

func JwtSign

func JwtSign(rsa bool, creator JwtClaimCreator) func(w rox.ResponseWriter, r *http.Request, a lokas.IProcess, next http.Handler)

func NewModuleFromRegistry

func NewModuleFromRegistry(s string) (lokas.IModule, error)

func RegisterModule

func RegisterModule(creator Creator)

func RegisterModulesFromPlugin

func RegisterModulesFromPlugin(path string) error

func SignToken

func SignToken(creator JwtClaimCreator, user interface{}, a lokas.IProcess, expire time.Duration, rsa bool) (string, error)

Types

type Actor

type Actor struct {
	lokas.IEntity

	OnUpdateFunc func()
	MsgHandler   func(actorId util.ID, transId uint32, msg protocol.ISerializable) (protocol.ISerializable, error)
	// contains filtered or unexported fields
}

func NewActor

func NewActor() *Actor

func (*Actor) Call

func (this *Actor) Call(actorId util.ID, req protocol.ISerializable) (protocol.ISerializable, error)

func (*Actor) GetLeaseId

func (this *Actor) GetLeaseId() (clientv3.LeaseID, bool, error)

return leaseId,(bool)is registered,error

func (*Actor) GetProcess

func (this *Actor) GetProcess() lokas.IProcess

func (*Actor) OnMessage

func (this *Actor) OnMessage(msg *protocol.RouteMessage)

func (*Actor) ReceiveMessage

func (this *Actor) ReceiveMessage(msg *protocol.RouteMessage)

func (*Actor) SendMessage

func (this *Actor) SendMessage(actorId util.ID, transId uint32, msg protocol.ISerializable) error

func (*Actor) SendReply

func (this *Actor) SendReply(actorId util.ID, transId uint32, msg protocol.ISerializable) error

func (*Actor) SetProcess

func (this *Actor) SetProcess(process lokas.IProcess)

func (*Actor) StartMessagePump

func (this *Actor) StartMessagePump()

func (*Actor) Update

func (this *Actor) Update(dt time.Duration, now time.Time)

type ActorContainer

type ActorContainer struct {
	Actors map[util.ID]lokas.IActor
	// contains filtered or unexported fields
}

func NewActorContainer

func NewActorContainer(process lokas.IProcess) *ActorContainer

func (*ActorContainer) AddActor

func (this *ActorContainer) AddActor(actor lokas.IActor)

func (*ActorContainer) GetActor

func (this *ActorContainer) GetActor(id util.ID) lokas.IActor

func (*ActorContainer) GetActorIds

func (this *ActorContainer) GetActorIds() []util.ID

func (*ActorContainer) GetProcess

func (this *ActorContainer) GetProcess() lokas.IProcess

func (*ActorContainer) Load

func (this *ActorContainer) Load(conf lokas.IConfig) error

func (*ActorContainer) OnStart

func (this *ActorContainer) OnStart() error

func (*ActorContainer) OnStop

func (this *ActorContainer) OnStop() error

func (*ActorContainer) RemoveActor

func (this *ActorContainer) RemoveActor(actor lokas.IActor)

func (*ActorContainer) RemoveActorById

func (this *ActorContainer) RemoveActorById(id util.ID) lokas.IActor

func (*ActorContainer) SetProcess

func (this *ActorContainer) SetProcess(process lokas.IProcess)

func (*ActorContainer) Start

func (this *ActorContainer) Start() *promise.Promise

func (*ActorContainer) StartActor

func (this *ActorContainer) StartActor(actor lokas.IActor)

func (*ActorContainer) Stop

func (this *ActorContainer) Stop() *promise.Promise

func (*ActorContainer) StopActor

func (this *ActorContainer) StopActor(actor lokas.IActor)

func (*ActorContainer) Type

func (this *ActorContainer) Type() string

func (*ActorContainer) Unload

func (this *ActorContainer) Unload() error

type ActorRegistry

type ActorRegistry struct {
	Id        util.ID
	ProcessId util.ProcessId
	Type      string
	GameId    string
	Version   string
	ServerId  int32
	//Health    lokas.ActorState
	Ts time.Time
}

func NewActorRegistry

func NewActorRegistry(id util.ID) *ActorRegistry

type ActorRegistryInfo

type ActorRegistryInfo struct {
	Id        util.ID
	Type      string
	ProcessId util.ProcessId
	GameId    string
	Version   string
	ServerId  int32
	Ts        time.Time
}

func CreateActorRegistryInfo

func CreateActorRegistryInfo(actor lokas.IActor) *ActorRegistryInfo

type AppConfig

type AppConfig struct {
	*viper.Viper
	// contains filtered or unexported fields
}

func NewAppConfig

func NewAppConfig(name string, opts ...ConfigOption) *AppConfig

func NewSubAppConfig

func NewSubAppConfig(name string, parent *AppConfig, conf *viper.Viper) *AppConfig

func (*AppConfig) AllSettings

func (this *AppConfig) AllSettings() map[string]interface{}

func (*AppConfig) Get

func (this *AppConfig) Get(key string) interface{}

func (*AppConfig) GetBool

func (this *AppConfig) GetBool(key string) bool

func (*AppConfig) GetDuration

func (this *AppConfig) GetDuration(key string) time.Duration

func (*AppConfig) GetFloat64

func (this *AppConfig) GetFloat64(key string) float64

func (*AppConfig) GetFolder

func (this *AppConfig) GetFolder() string

func (*AppConfig) GetInt

func (this *AppConfig) GetInt(key string) int

func (*AppConfig) GetIntSlice

func (this *AppConfig) GetIntSlice(key string) []int

func (*AppConfig) GetSizeInBytes

func (this *AppConfig) GetSizeInBytes(key string) uint

func (*AppConfig) GetString

func (this *AppConfig) GetString(key string) string

func (*AppConfig) GetStringMap

func (this *AppConfig) GetStringMap(key string) map[string]interface{}

func (*AppConfig) GetStringMapString

func (this *AppConfig) GetStringMapString(key string) map[string]string

func (*AppConfig) GetStringMapStringSlice

func (this *AppConfig) GetStringMapStringSlice(key string) map[string][]string

func (*AppConfig) GetStringSlice

func (this *AppConfig) GetStringSlice(key string) []string

func (*AppConfig) GetTime

func (this *AppConfig) GetTime(key string) time.Time

func (*AppConfig) IsSet

func (this *AppConfig) IsSet(key string) bool

func (*AppConfig) Load

func (this *AppConfig) Load() error

func (*AppConfig) LoadFromRemote

func (this *AppConfig) LoadFromRemote() error

func (*AppConfig) Save

func (this *AppConfig) Save() error

func (*AppConfig) Set

func (this *AppConfig) Set(key string, value interface{})

func (*AppConfig) SetFolder

func (this *AppConfig) SetFolder(f string)

func (*AppConfig) SetRemoteConfig

func (this *AppConfig) SetRemoteConfig(p string, etcd string)

func (*AppConfig) Sub

func (this *AppConfig) Sub(key string) lokas.IConfig

type Avatar

type Avatar struct {
	*Actor
	GameId   string
	ServerId int32
}

func NewAvatar

func NewAvatar(id util.ID) *Avatar

func (*Avatar) Deserialize

func (this *Avatar) Deserialize(a lokas.IProcess) error

func (*Avatar) Load

func (this *Avatar) Load(conf lokas.IConfig) error

func (*Avatar) OnStart

func (this *Avatar) OnStart() error

func (*Avatar) OnStop

func (this *Avatar) OnStop() error

func (*Avatar) Serialize

func (this *Avatar) Serialize(a lokas.IProcess) error

func (*Avatar) Start

func (this *Avatar) Start() *promise.Promise

func (*Avatar) Stop

func (this *Avatar) Stop() *promise.Promise

func (*Avatar) Type

func (this *Avatar) Type() string

func (*Avatar) Unload

func (this *Avatar) Unload() error

type AvatarManager

type AvatarManager struct {
	*Actor
	Avatars map[util.ID]*Avatar
	// contains filtered or unexported fields
}

func (*AvatarManager) CreateAvatar

func (this *AvatarManager) CreateAvatar(id util.ID) (*Avatar, error)

func (*AvatarManager) GetAvatar

func (this *AvatarManager) GetAvatar(id util.ID) *Avatar

func (*AvatarManager) Load

func (this *AvatarManager) Load(conf lokas.IConfig) error

func (*AvatarManager) OnStart

func (this *AvatarManager) OnStart() error

func (*AvatarManager) OnStop

func (this *AvatarManager) OnStop() error

func (*AvatarManager) OnUpdate

func (this *AvatarManager) OnUpdate()

func (*AvatarManager) RemoveAvatar

func (this *AvatarManager) RemoveAvatar(id util.ID)

func (*AvatarManager) Start

func (this *AvatarManager) Start() *promise.Promise

func (*AvatarManager) Stop

func (this *AvatarManager) Stop() *promise.Promise

func (*AvatarManager) Type

func (this *AvatarManager) Type() string

func (*AvatarManager) Unload

func (this *AvatarManager) Unload() error

type Block

type Block struct {
}

basic data unit,represent a block of gamespace

type Cell

type Cell struct {
	*Actor
	Blocks map[int64]Block
}

unit processor of world server/game room

type CellManager

type CellManager struct {
	*Actor
	ActorContainer
	Blocks map[int64]Block
}

func (*CellManager) Load

func (this *CellManager) Load(conf lokas.IConfig) error

func (*CellManager) OnStart

func (this *CellManager) OnStart() error

func (*CellManager) OnStop

func (this *CellManager) OnStop() error

func (*CellManager) Spawn

func (this *CellManager) Spawn() lokas.IActor

func (*CellManager) Unload

func (this *CellManager) Unload() error

type Center

type Center struct {
	*Actor
	UseEtcd bool
}

func (*Center) Load

func (this *Center) Load(conf lokas.IConfig) error

func (*Center) OnCreate

func (this *Center) OnCreate() error

func (*Center) OnDestroy

func (this *Center) OnDestroy() error

func (*Center) OnRegister

func (this *Center) OnRegister()

func (*Center) OnStart

func (this *Center) OnStart() error

func (*Center) OnStop

func (this *Center) OnStop() error

func (*Center) Start

func (this *Center) Start() *promise.Promise

func (*Center) Stop

func (this *Center) Stop() *promise.Promise

func (*Center) Type

func (this *Center) Type() string

func (*Center) Unload

func (this *Center) Unload() error

type ClientSession

type ClientSession struct {
	*Actor
	Verified bool
	Messages chan []byte
	Conn     lokas.IConn
	Protocol protocol.TYPE

	OnCloseFunc      func(conn lokas.IConn)
	OnOpenFunc       func(conn lokas.IConn)
	ClientMsgHandler func(msg *protocol.BinaryMessage)
	AuthFunc         func(data []byte) error
	// contains filtered or unexported fields
}

func NewClientSession

func NewClientSession(conn lokas.IConn, id util.ID, manager lokas.ISessionManager, opts ...SessionOption) *ClientSession

func (*ClientSession) GetConn

func (this *ClientSession) GetConn() lokas.IConn

func (*ClientSession) Load

func (this *ClientSession) Load(conf lokas.IConfig) error

func (*ClientSession) OnClose

func (this *ClientSession) OnClose(conn lokas.IConn)

func (*ClientSession) OnCreate

func (this *ClientSession) OnCreate() error

func (*ClientSession) OnDestroy

func (this *ClientSession) OnDestroy() error

func (*ClientSession) OnOpen

func (this *ClientSession) OnOpen(conn lokas.IConn)

func (*ClientSession) OnRecv

func (this *ClientSession) OnRecv(conn lokas.IConn, data []byte)

func (*ClientSession) OnStart

func (this *ClientSession) OnStart() error

func (*ClientSession) OnStop

func (this *ClientSession) OnStop() error

func (*ClientSession) Start

func (this *ClientSession) Start() *promise.Promise

func (*ClientSession) StartMessagePump

func (this *ClientSession) StartMessagePump()

func (*ClientSession) Stop

func (this *ClientSession) Stop() *promise.Promise

func (*ClientSession) Type

func (this *ClientSession) Type() string

func (*ClientSession) Unload

func (this *ClientSession) Unload() error

type CommonRegistry

type CommonRegistry struct {
	Processes      map[util.ProcessId]*ProcessRegistry
	Service        map[protocol.BINARY_TAG]*ServiceRegistry
	Actors         map[util.ID]*ActorRegistry
	ActorsByType   map[string][]util.ID
	ActorsByServer map[int32][]util.ID
	Ts             time.Time
	// contains filtered or unexported fields
}

func NewCommonRegistry

func NewCommonRegistry() *CommonRegistry

func (*CommonRegistry) AddActor

func (this *CommonRegistry) AddActor(actor *ActorRegistry)

func (*CommonRegistry) AddProcess

func (this *CommonRegistry) AddProcess(process *ProcessRegistry)

func (*CommonRegistry) AddService

func (this *CommonRegistry) AddService(service *ServiceRegistry)

func (*CommonRegistry) GetActorIdsByTypeAndServerId

func (this *CommonRegistry) GetActorIdsByTypeAndServerId(serverId int32, typ string) []util.ID

func (*CommonRegistry) GetActorRegistry

func (this *CommonRegistry) GetActorRegistry(id util.ID) *ActorRegistry

func (*CommonRegistry) RemoveActor

func (this *CommonRegistry) RemoveActor(actorId util.ID)

func (*CommonRegistry) RemoveProcess

func (this *CommonRegistry) RemoveProcess(id util.ProcessId)

func (*CommonRegistry) RemoveService

func (this *CommonRegistry) RemoveService(id protocol.BINARY_TAG)

type ConfigOption

type ConfigOption func(*AppConfig) *AppConfig

func ConfigFile

func ConfigFile(folder string) ConfigOption

func EtcdFile

func EtcdFile(etcdPath string, addr string) ConfigOption

func MongoFile

func MongoFile(folder string) ConfigOption

type ConnType

type ConnType int
const (
	TCP       ConnType = 0
	Websocket ConnType = 1
)

func String2ConnType

func String2ConnType(s string) ConnType

func (ConnType) String

func (this ConnType) String() string

type Context

type Context struct {
	Content map[string]interface{} `json:"content"`
}

func NewContext

func NewContext() *Context

func (*Context) Get

func (this *Context) Get(key string) interface{}

func (*Context) GetIdType

func (this *Context) GetIdType(key string) util.ID

func (*Context) GetProcessIdType

func (this *Context) GetProcessIdType(key string) util.ProcessId

func (*Context) GetString

func (this *Context) GetString(key string) string

func (*Context) Set

func (this *Context) Set(key string, value interface{})

type Creator

type Creator func() lokas.IModule

type DefaultConfig

type DefaultConfig struct {
	*AppConfig
	ProcessId util.ProcessId  `mapstructure:"pid"`
	ServerId  int32           `mapstructure:"sid"`
	GameId    string          `mapstructure:"gid"`
	Version   string          `mapstructure:"version"`
	SName     string          `mapstructure:"serverName"`
	Name      string          `mapstructure:"name"`
	Type      string          `mapstructure:"type"`
	Host      string          `mapstructure:"host"`
	Port      string          `mapstructure:"port"`
	Etcd      EtcdConfig      `mapstructure:"-"`
	Mongo     MongoConfig     `mapstructure:"-"`
	Mysql     MysqlConfig     `mapstructure:"-"`
	Redis     RedisConfig     `mapstructure:"-"`
	Mods      []lokas.IConfig `mapstructure:"-"`
	Modules   []string        `mapstructure:"modules"`
}

func NewDefaultConfig

func NewDefaultConfig() *DefaultConfig

func (*DefaultConfig) GetAllSub

func (this *DefaultConfig) GetAllSub() []lokas.IConfig

func (*DefaultConfig) GetDb

func (this *DefaultConfig) GetDb(t string) interface{}

func (*DefaultConfig) GetGameId

func (this *DefaultConfig) GetGameId() string

func (*DefaultConfig) GetIdType

func (this *DefaultConfig) GetIdType(key string) util.ID

func (*DefaultConfig) GetName

func (this *DefaultConfig) GetName() string

func (*DefaultConfig) GetProcessId

func (this *DefaultConfig) GetProcessId() util.ProcessId

func (*DefaultConfig) GetProcessIdType

func (this *DefaultConfig) GetProcessIdType(key string) util.ProcessId

func (*DefaultConfig) GetServerId

func (this *DefaultConfig) GetServerId() int32

func (*DefaultConfig) GetVersion

func (this *DefaultConfig) GetVersion() string

func (*DefaultConfig) Load

func (this *DefaultConfig) Load() error

func (*DefaultConfig) LoadFromRemote

func (this *DefaultConfig) LoadFromRemote() error

func (*DefaultConfig) LoadFromString

func (this *DefaultConfig) LoadFromString(s string) error

func (*DefaultConfig) ServerName

func (this *DefaultConfig) ServerName() string

type EtcdConfig

type EtcdConfig struct {
	EndPoints []string `mapstructure:"endpoints"`
}

type Gate

type Gate struct {
	*Actor
	lokas.ISessionManager
	Host               string
	Port               string
	AuthFunc           func(data []byte) error
	SessionCreatorFunc func(conn lokas.IConn) lokas.ISession
	Protocol           protocol.TYPE
	// contains filtered or unexported fields
}

func (*Gate) Load

func (this *Gate) Load(conf lokas.IConfig) error

func (*Gate) OnCreate

func (this *Gate) OnCreate() error

func (*Gate) OnDestroy

func (this *Gate) OnDestroy() error

func (*Gate) OnStart

func (this *Gate) OnStart() error

func (*Gate) OnStop

func (this *Gate) OnStop() error

func (*Gate) SessionCreator

func (this *Gate) SessionCreator(conn lokas.IConn) lokas.ISession

func (*Gate) Start

func (this *Gate) Start() *promise.Promise

func (*Gate) Stop

func (this *Gate) Stop() *promise.Promise

func (*Gate) Type

func (this *Gate) Type() string

func (*Gate) Unload

func (this *Gate) Unload() error

type Http

type Http struct {
	*Actor
	Host string
	Port string
	// contains filtered or unexported fields
}

func (*Http) CreateHandlerFunc

func (this *Http) CreateHandlerFunc(f rox.Handler) func(http.ResponseWriter, *http.Request)

func (*Http) HandleFunc

func (this *Http) HandleFunc(path string, f rox.Handler) *rox.Route

func (*Http) Load

func (this *Http) Load(conf lokas.IConfig) error

func (*Http) MatchRouter

func (this *Http) MatchRouter(s string) *rox.Router

func (*Http) OnCreate

func (this *Http) OnCreate() error

func (*Http) OnDestroy

func (this *Http) OnDestroy() error

func (*Http) OnStart

func (this *Http) OnStart() error

func (*Http) OnStop

func (this *Http) OnStop() error

func (*Http) Path

func (this *Http) Path(s string) *rox.Route

func (*Http) PathExcept

func (this *Http) PathExcept(p string, m ...rox.MiddleWare) *Http

func (*Http) PathExcepts

func (this *Http) PathExcepts(p []string, m ...rox.MiddleWare) *Http

func (*Http) PathIn

func (this *Http) PathIn(p []string, m ...rox.MiddleWare) *Http

func (*Http) PathOnly

func (this *Http) PathOnly(p string, m ...rox.MiddleWare) *Http

func (*Http) PathPrefix

func (this *Http) PathPrefix(s string) *rox.Route

func (*Http) PrefixExcept

func (this *Http) PrefixExcept(prefix string, m ...rox.MiddleWare) *Http

func (*Http) PrefixExceptStrict

func (this *Http) PrefixExceptStrict(prefix string, m ...rox.MiddleWare) *Http

func (*Http) PrefixOnly

func (this *Http) PrefixOnly(prefix string, m ...rox.MiddleWare) *Http

func (*Http) PrefixOnlyStrict

func (this *Http) PrefixOnlyStrict(prefix string, m ...rox.MiddleWare) *Http

func (*Http) Start

func (this *Http) Start() *promise.Promise

func (*Http) Stop

func (this *Http) Stop() *promise.Promise

func (*Http) Type

func (this *Http) Type() string

func (*Http) Unload

func (this *Http) Unload() error

func (*Http) Use

func (this *Http) Use(m ...rox.MiddleWare) *Http

func (*Http) When

func (this *Http) When(matcher rox.MiddlewareMatcher, m ...rox.MiddleWare) *Http

type JwtClaim

type JwtClaim struct {
	Create time.Time
	Expire int64
}

func NewJwtClaim

func NewJwtClaim(expire time.Duration) *JwtClaim

func (*JwtClaim) Marshal

func (this *JwtClaim) Marshal() ([]byte, error)

func (*JwtClaim) Unmarshal

func (this *JwtClaim) Unmarshal(v []byte) error

func (*JwtClaim) Valid

func (this *JwtClaim) Valid() error

type JwtClaimCreator

type JwtClaimCreator func(user interface{}, expire time.Duration) JwtClaimWithUser

type JwtClaimWithUser

type JwtClaimWithUser interface {
	jwt.Claims
	GetUser() interface{}
	SetUser(user interface{})
}

type MongoConfig

type MongoConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Database string `mapstructure:"database"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
}

type MysqlConfig

type MysqlConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Database string `mapstructure:"database"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
}

type Process

type Process struct {
	lokas.IActorContainer
	lokas.IRegistry
	lokas.IRouter
	// contains filtered or unexported fields
}

func CreateProcess

func CreateProcess() *Process

func (*Process) Add

func (this *Process) Add(mod lokas.IModule) lokas.IModule

func (*Process) Config

func (this *Process) Config() lokas.IConfig

func (*Process) GameId

func (this *Process) GameId() string

func (*Process) GameServerId

func (this *Process) GameServerId() string

func (*Process) GenId

func (this *Process) GenId() util.ID

GenId generate snowflake id

func (*Process) Get

func (this *Process) Get(name string) lokas.IModule

func (*Process) GetEtcd

func (this *Process) GetEtcd() *etcdclient.Client

func (*Process) GetLogger

func (this *Process) GetLogger() *log.ComposeLogger

func (*Process) GetMongo

func (this *Process) GetMongo() *qmgo.Database

func (*Process) GetRedis

func (this *Process) GetRedis() *redisclient.Client

func (*Process) GlobalMutex

func (this *Process) GlobalMutex(key string, ttl int) (*etcdclient.Mutex, error)

func (*Process) Id

func (this *Process) Id() util.ProcessId

func (*Process) Load

func (this *Process) Load(config lokas.IProcessConfig) error

func (*Process) LoadAllModule

func (this *Process) LoadAllModule(conf lokas.IProcessConfig) error

func (*Process) LoadMod

func (this *Process) LoadMod(name string, conf lokas.IConfig) error

func (*Process) LoadModuleRegistry

func (this *Process) LoadModuleRegistry() error

func (*Process) RegisterModule

func (this *Process) RegisterModule(creator lokas.IModuleCtor)

func (*Process) SaveModuleRegistry

func (this *Process) SaveModuleRegistry() error

func (*Process) ServerId

func (this *Process) ServerId() int32

func (*Process) Start

func (this *Process) Start() error

func (*Process) StartAllModule

func (this *Process) StartAllModule() error

func (*Process) Stop

func (this *Process) Stop() error

func (*Process) StopAllModule

func (this *Process) StopAllModule() error

func (*Process) UnloadMod

func (this *Process) UnloadMod(name string) error

func (*Process) Version

func (this *Process) Version() string

type ProcessActorsInfo

type ProcessActorsInfo struct {
	Id     util.ProcessId
	Actors []util.ID
	Ts     time.Time
}

func CreateProcessActorsInfo

func CreateProcessActorsInfo(process lokas.IProcess) *ProcessActorsInfo

type ProcessRegistry

type ProcessRegistry struct {
	Id       util.ProcessId
	GameId   string
	Version  string
	ServerId int32
	Host     string
	Port     string
	Services map[protocol.BINARY_TAG]*lokas.Service
	Actors   map[util.ID]*ActorRegistry
	Ts       time.Time
}

func NewProcessRegistry

func NewProcessRegistry(id util.ProcessId) *ProcessRegistry

type ProcessRegistryInfo

type ProcessRegistryInfo struct {
	Id       util.ProcessId
	GameId   string
	Version  string
	ServerId int32
	Host     string
	Port     string
	Ts       time.Time
}

func CreateProcessRegistryInfo

func CreateProcessRegistryInfo(process lokas.IProcess) *ProcessRegistryInfo

type ProcessServiceInfo

type ProcessServiceInfo struct {
	Id       util.ProcessId
	Services map[protocol.BINARY_TAG]int
}

type Proxy

type Proxy struct {
	*Actor

	lokas.ISessionManager
	// contains filtered or unexported fields
}

func (*Proxy) Connect

func (this *Proxy) Connect(id util.ProcessId, addr string) error

func (*Proxy) Load

func (this *Proxy) Load(conf lokas.IConfig) error

func (*Proxy) OnCreate

func (this *Proxy) OnCreate() error

func (*Proxy) OnDestroy

func (this *Proxy) OnDestroy() error

func (*Proxy) OnStart

func (this *Proxy) OnStart() error

func (*Proxy) OnStop

func (this *Proxy) OnStop() error

func (*Proxy) Start

func (this *Proxy) Start() *promise.Promise

func (*Proxy) Stop

func (this *Proxy) Stop() *promise.Promise

func (*Proxy) Type

func (this *Proxy) Type() string

func (*Proxy) Unload

func (this *Proxy) Unload() error

type RedisConfig

type RedisConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Password string `mapstructure:"password"`
}

type Registry

type Registry struct {
	LocalRegistry  *CommonRegistry //local actor&service registry
	GlobalRegistry *CommonRegistry //local actor&service registry
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(process lokas.IProcess) *Registry

func (*Registry) GetActorIdsByTypeAndServerId

func (this *Registry) GetActorIdsByTypeAndServerId(serverId int32, typ string) []util.ID

func (*Registry) GetProcess

func (this *Registry) GetProcess() lokas.IProcess

func (*Registry) GetProcessIdByActor

func (this *Registry) GetProcessIdByActor(actorId util.ID) (util.ProcessId, error)

func (*Registry) Load

func (this *Registry) Load(conf lokas.IConfig) error

func (*Registry) OnCreate

func (this *Registry) OnCreate() error

func (*Registry) OnDestroy

func (this *Registry) OnDestroy() error

func (*Registry) OnStart

func (this *Registry) OnStart() error

func (*Registry) OnStop

func (this *Registry) OnStop() error

func (*Registry) QueryRemoteActorsByServer

func (this *Registry) QueryRemoteActorsByServer(typ string, ServerId int32) []*Actor

func (*Registry) QueryRemoteActorsByType

func (this *Registry) QueryRemoteActorsByType(typ string) []*Actor

func (*Registry) RegisterActorLocal

func (this *Registry) RegisterActorLocal(actor lokas.IActor) error

func (*Registry) RegisterActorRemote

func (this *Registry) RegisterActorRemote(actor lokas.IActor) error

func (*Registry) RegisterActors

func (this *Registry) RegisterActors() error

func (*Registry) RegisterProcessInfo

func (this *Registry) RegisterProcessInfo() error

func (*Registry) RegisterServiceLocal

func (this *Registry) RegisterServiceLocal(service *lokas.Service) error

TODO

func (*Registry) RegisterServiceRemote

func (this *Registry) RegisterServiceRemote(service *lokas.Service) error

func (*Registry) RegistryServices

func (this *Registry) RegistryServices()

func (*Registry) SetProcess

func (this *Registry) SetProcess(process lokas.IProcess)

func (*Registry) Start

func (this *Registry) Start() *promise.Promise

func (*Registry) Stop

func (this *Registry) Stop() *promise.Promise

func (*Registry) Type

func (this *Registry) Type() string

func (*Registry) Unload

func (this *Registry) Unload() error

func (*Registry) UnregisterActorLocal

func (this *Registry) UnregisterActorLocal(actor lokas.IActor) error

func (*Registry) UnregisterActorRemote

func (this *Registry) UnregisterActorRemote(actor lokas.IActor) error

func (*Registry) UnregisterServiceLocal

func (this *Registry) UnregisterServiceLocal(service *lokas.Service) error

func (*Registry) UnregisterServiceRemote

func (this *Registry) UnregisterServiceRemote(service *lokas.Service) error

type Router

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

router读取配置表,同步服务器注册信息 路由信息到本机或调用Proxy建立连接

func NewRouter

func NewRouter(process lokas.IProcess) *Router

func (*Router) GetProcess

func (this *Router) GetProcess() lokas.IProcess

func (*Router) Load

func (this *Router) Load(conf lokas.IConfig) error

func (*Router) OnStart

func (this *Router) OnStart() error

func (*Router) OnStop

func (this *Router) OnStop() error

func (*Router) RouteMsg

func (this *Router) RouteMsg(msg *protocol.RouteMessage)

func (*Router) SetProcess

func (this *Router) SetProcess(process lokas.IProcess)

func (*Router) Start

func (this *Router) Start() *promise.Promise

func (*Router) Stop

func (this *Router) Stop() *promise.Promise

func (*Router) Type

func (this *Router) Type() string

func (*Router) Unload

func (this *Router) Unload() error

type ServiceRegistry

type ServiceRegistry struct {
	Id          protocol.BINARY_TAG
	ServiceType lokas.ServiceType
	GameId      string
	Version     string
	ServerId    uint32
	Weights     map[util.ID]int
	Ts          time.Time
}

type SessionOption

type SessionOption func(*ClientSession)

func WithAuthFunc

func WithAuthFunc(authFunc func(data []byte) error) SessionOption

func WithCloseFunc

func WithCloseFunc(closeFunc func(conn lokas.IConn)) SessionOption

func WithOpenFunc

func WithOpenFunc(openFunc func(conn lokas.IConn)) SessionOption

func WithProtocol

func WithProtocol(protocol protocol.TYPE) SessionOption

func WithTimeout

func WithTimeout(timeout time.Duration) SessionOption

type User

type User struct {
	Id   util.ID
	Role uint8
}

type UserCreator

type UserCreator func() interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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