lox

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 54 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TimeOut                  = time.Second * 120
	UpdateTime               = time.Second * 15
	LeaseDuration      int64 = 23
	LeaseRenewDuration int64 = 15
)
View Source
const (
	MUTEX_AVATAR_SESSION_KEY lokas.Key = "avatar_session_%d"
	AVATAR_SESSION_KEY       lokas.Key = "/avatar_session/%d"
)
View Source
const (
	TAG_USER             = 130
	TAG_JWT              = 131
	TAG_CLAIM_USER       = 132
	TAG_AVATAR_MAP       = 133
	TAG_AVATAR           = 134
	TAG_ADMIN_CMD        = 135
	TAG_ADMIN_CMD_RESULT = 136
	TAG_CREATE_AVATAR    = 137
	TAG_KICK_AVATAR      = 138
	TAG_RESPONSE         = 140
	TAG_CONSOLE_EVENT    = 221
)
View Source
const (
	HeaderSize            = 8
	ProtectLongPacketSize = 8 * 1024 * 1024
)
View Source
const (
	ETCD_SERVICE_PREFIX_KEY = "/service/"
)
View Source
const (
	PingInterval = time.Second * 3
)
View Source
const REFRESH_TOKEN_EXPIRE_TIME = time.Hour * 24 * 30
View Source
const TOKEN_EXPIRE_TIME = time.Minute * 10

Variables

View Source
var CenterCtor = centerCtor{}
View Source
var GateCtor = gateCtor{}
View Source
var HttpCtor = httpCtor{}
View Source
var ProxyCtor = proxyCtor{}
View Source
var StatCtor = statCtor{}

Functions

func CreateUser added in v0.1.29

func CreateUser() interface{}

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 LogUserInfo added in v0.1.29

func LogUserInfo(user *User) log.ZapFields

func NewAvatarManagerCtor added in v0.1.29

func NewAvatarManagerCtor(option lokas.IGameHandler) avatarManagerCtor

func NewModuleFromRegistry

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

func NewWebSocket added in v0.1.35

func NewWebSocket(url string, client *WsClient, p protocol.TYPE) (*wsImpl, error)

func ReadDataFromEtcd added in v0.2.24

func ReadDataFromEtcd(addr string, path string) (*bytes.Buffer, 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)

func UserId added in v0.1.29

func UserId(user *User) zap.Field

func UserRefreshToken added in v0.1.29

func UserRefreshToken(user *User) zap.Field

func UserToken added in v0.1.29

func UserToken(user *User) zap.Field

Types

type AccState added in v0.1.29

type AccState uint32
const (
	ACC_NORMAL    AccState = 0
	ACC_MUTE      AccState = 1
	ACC_FROST     AccState = 8
	ACC_FORBIDDEN AccState = 9
)

type ActiveSession added in v0.0.6

type ActiveSession struct {
	util.ID

	Messages chan []byte
	Conn     lokas.IConn
	Protocol protocol.TYPE

	OnCloseFunc func(conn lokas.IConn)
	OnOpenFunc  func(conn lokas.IConn)
	OnVerified  func(conn lokas.IConn)
	MsgHandler  func(msg *protocol.BinaryMessage)
	// contains filtered or unexported fields
}

func NewActiveSession added in v0.0.6

func NewActiveSession(conn lokas.IConn, id util.ID, manager lokas.ISessionManager, opts ...ActiveSessionOption) *ActiveSession

func (*ActiveSession) AsyncCall added in v0.0.6

func (this *ActiveSession) AsyncCall(actorId util.ID, transId uint32, req protocol.ISerializable, resp protocol.ISerializable) error

func (*ActiveSession) Call added in v0.0.6

func (this *ActiveSession) Call(actorId util.ID, transId uint32, req protocol.ISerializable, resp protocol.ISerializable) error

func (*ActiveSession) CloneEntity added in v0.0.6

func (this *ActiveSession) CloneEntity() *ecs.Entity

func (*ActiveSession) GetConn added in v0.0.6

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

func (*ActiveSession) GetId added in v0.0.6

func (this *ActiveSession) GetId() util.ID

func (*ActiveSession) GetProcess added in v0.0.6

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

func (*ActiveSession) OnClose added in v0.0.6

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

func (*ActiveSession) OnCreate added in v0.0.6

func (this *ActiveSession) OnCreate() error

func (*ActiveSession) OnDestroy added in v0.0.6

func (this *ActiveSession) OnDestroy() error

func (*ActiveSession) OnMessage added in v0.0.6

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

func (*ActiveSession) OnOpen added in v0.0.6

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

func (*ActiveSession) OnRecv added in v0.0.6

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

func (*ActiveSession) PongHandler added in v0.0.6

func (this *ActiveSession) PongHandler(pong *protocol.Pong)

func (*ActiveSession) SendMessage added in v0.0.6

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

func (*ActiveSession) SetId added in v0.0.6

func (this *ActiveSession) SetId(id util.ID)

func (*ActiveSession) SetProcess added in v0.0.6

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

func (*ActiveSession) Start added in v0.0.6

func (this *ActiveSession) Start() error

func (*ActiveSession) Stop added in v0.0.6

func (this *ActiveSession) Stop() error

func (*ActiveSession) Type added in v0.0.6

func (this *ActiveSession) Type() string

func (*ActiveSession) Update added in v0.0.6

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

func (*ActiveSession) Write added in v0.0.6

func (this *ActiveSession) Write(data []byte) error

type ActiveSessionOption added in v0.1.25

type ActiveSessionOption func(*ActiveSession)

type Actor

type Actor struct {
	lokas.IEntity
	timer.TimeHandler

	MsgChan      chan *protocol.RouteMessage
	ReplyChan    chan *protocol.RouteMessage
	ReqContexts  map[uint32]lokas.IReqContext
	Timeout      time.Duration
	CtxMutex     sync.Mutex
	Timer        *time.Ticker
	DoneChan     chan struct{}
	OnUpdateFunc func()
	MsgHandler   func(actorId util.ID, transId uint32, msg protocol.ISerializable) (protocol.ISerializable, error)

	DataChan      chan *protocol.RouteDataMsg
	ReplyDataChan chan *protocol.RouteDataMsg

	Ctx    context.Context
	Cancel context.CancelFunc

	MQChan chan *nats.Msg
	Sub    *mq.ActorSubscriber
	// 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) CreateSubscriber added in v0.3.28

func (this *Actor) CreateSubscriber() (err 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) HandleMsg added in v0.1.41

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

func (*Actor) HookReceive added in v0.1.41

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

func (*Actor) Load added in v0.1.25

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

func (*Actor) LogInfo added in v0.3.34

func (this *Actor) LogInfo() log.ZapFields

func (*Actor) OnMessage

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

func (*Actor) OnRecvData added in v0.3.6

func (this *Actor) OnRecvData(dataMsg *protocol.RouteDataMsg)

func (*Actor) OnRecvMQ added in v0.3.28

func (this *Actor) OnRecvMQ(mqMsg *nats.Msg) (errRet error)

func (*Actor) OnStart added in v0.1.25

func (this *Actor) OnStart() error

func (*Actor) OnStop added in v0.1.25

func (this *Actor) OnStop() error

func (*Actor) PId added in v0.1.4

func (this *Actor) PId() util.ProcessId

func (*Actor) Publish added in v0.3.28

func (this *Actor) Publish(key string, msg protocol.ISerializable) error

func (*Actor) ReceiveData added in v0.3.6

func (this *Actor) ReceiveData(msg *protocol.RouteDataMsg) error

func (*Actor) ReceiveMessage

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

func (*Actor) Request added in v0.3.34

func (this *Actor) Request(key string, msg protocol.ISerializable) (protocol.ISerializable, error)

func (*Actor) Send added in v0.1.25

func (this *Actor) Send(id util.ProcessId, msg *protocol.RouteMessage) error

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) SetType added in v0.0.9

func (this *Actor) SetType(s string)

func (*Actor) Start added in v0.1.25

func (this *Actor) Start() error

func (*Actor) StartMessagePump

func (this *Actor) StartMessagePump()

func (*Actor) Stop added in v0.1.25

func (this *Actor) Stop() error

func (*Actor) Subscribe added in v0.3.28

func (this *Actor) Subscribe(key string) error

func (*Actor) Type added in v0.0.9

func (this *Actor) Type() string

func (*Actor) Unload added in v0.1.25

func (this *Actor) Unload() error

func (*Actor) Unsubscribe added in v0.3.28

func (this *Actor) Unsubscribe(key string) error

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() error

func (*ActorContainer) StartActor

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

func (*ActorContainer) Stop

func (this *ActorContainer) Stop() error

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 AdminCommand added in v0.1.29

type AdminCommand struct {
	Command  string
	Username string
	Params   []string
}

func NewAdminCommand added in v0.1.29

func NewAdminCommand(cmd string, username string, params ...interface{}) *AdminCommand

func (*AdminCommand) GetId added in v0.1.29

func (this *AdminCommand) GetId() (protocol.BINARY_TAG, error)

func (*AdminCommand) ParamsValue added in v0.1.29

func (this *AdminCommand) ParamsValue() *cmds.ParamsValue

func (*AdminCommand) Serializable added in v0.1.29

func (this *AdminCommand) Serializable() protocol.ISerializable

type AdminCommandResult added in v0.1.29

type AdminCommandResult struct {
	Command  string
	Username string
	Success  bool
	Data     []byte
}

func NewAdminCommandResult added in v0.1.29

func NewAdminCommandResult(cmd *AdminCommand, success bool, data []byte) *AdminCommandResult

func (*AdminCommandResult) GetId added in v0.1.29

func (this *AdminCommandResult) GetId() (protocol.BINARY_TAG, error)

func (*AdminCommandResult) Serializable added in v0.1.29

func (this *AdminCommandResult) Serializable() protocol.ISerializable

type AdminHandShake added in v0.1.29

type AdminHandShake struct {
	Account  string
	Password string
}

func NewAdminHandShake added in v0.1.29

func NewAdminHandShake(acc string, pass string) *AdminHandShake

func (*AdminHandShake) Marshal added in v0.1.29

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

func (*AdminHandShake) Unmarshal added in v0.1.29

func (this *AdminHandShake) Unmarshal(from []byte) error

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) GetInt32Slice added in v0.2.4

func (this *AppConfig) GetInt32Slice(key string) []int32

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) LoadFromLocal added in v0.3.37

func (this *AppConfig) LoadFromLocal() 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
	*AvatarSession

	Serializer   func(avatar lokas.IActor, process lokas.IProcess) error
	Initializer  func(avatar lokas.IActor, process lokas.IProcess) error
	Deserializer func(avatar lokas.IActor, process lokas.IProcess) error
	Updater      func(avatar lokas.IActor, process lokas.IProcess) error
	MsgDelegator func(avatar lokas.IActor, actorId util.ID, transId uint32, msg protocol.ISerializable) (protocol.ISerializable, error)
	ClientHost   string
	// contains filtered or unexported fields
}

func NewAvatar

func NewAvatar(id util.ID, handler lokas.IGameHandler, manager *AvatarManager) *Avatar

func (*Avatar) Deserialize

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

func (*Avatar) Initialize added in v0.2.6

func (this *Avatar) Initialize(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) OnUpdate added in v0.1.29

func (this *Avatar) OnUpdate()

func (*Avatar) SendEvent added in v0.1.29

func (this *Avatar) SendEvent(msg protocol.ISerializable) error

func (*Avatar) Serialize

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

func (*Avatar) Start

func (this *Avatar) Start() error

func (*Avatar) Stop

func (this *Avatar) Stop() error

func (*Avatar) Unload

func (this *Avatar) Unload() error

type AvatarManager

type AvatarManager struct {
	*Actor
	Avatars   map[util.ID]*Avatar
	AvatarCnt int32
	Option    lokas.IGameHandler
	Mu        sync.Mutex
	Ctx       context.Context
	Cancel    context.CancelFunc
}

func (*AvatarManager) CreateAvatar

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

func (*AvatarManager) GetAvatar

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

func (*AvatarManager) HandleMsg added in v0.1.29

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

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() error

func (*AvatarManager) Stop

func (this *AvatarManager) Stop() error

func (*AvatarManager) Unload

func (this *AvatarManager) Unload() error

type AvatarMap added in v0.1.29

type AvatarMap struct {
	Id         util.ID `bson:"_id"`
	UserId     util.ID
	GameId     string
	ServerId   int32
	UserName   string
	AvatarName string
}

type AvatarSession added in v0.1.29

type AvatarSession struct {
	Id       util.ID
	UserId   util.ID
	GateId   util.ID
	UserName string
	GameId   string
	ServerId int32
	// contains filtered or unexported fields
}

func NewAvatarSession added in v0.1.29

func NewAvatarSession(id util.ID) *AvatarSession

func (*AvatarSession) ChangeUserName added in v0.1.35

func (this *AvatarSession) ChangeUserName(a lokas.IProcess, name string) error

func (*AvatarSession) Deserialize added in v0.1.29

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

func (*AvatarSession) FetchData added in v0.1.29

func (this *AvatarSession) FetchData(a lokas.IProcess) error

func (*AvatarSession) GetGameId added in v0.1.29

func (this *AvatarSession) GetGameId() string

func (*AvatarSession) GetGateId added in v0.1.29

func (this *AvatarSession) GetGateId() util.ID

func (*AvatarSession) GetId added in v0.1.29

func (this *AvatarSession) GetId() util.ID

func (*AvatarSession) GetServerId added in v0.1.29

func (this *AvatarSession) GetServerId() int32

func (*AvatarSession) GetUserId added in v0.1.35

func (this *AvatarSession) GetUserId() util.ID

func (*AvatarSession) GetUserName added in v0.1.29

func (this *AvatarSession) GetUserName() string

func (*AvatarSession) Initialize added in v0.2.7

func (this *AvatarSession) Initialize(a lokas.IProcess) error

func (*AvatarSession) Serialize added in v0.1.29

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

func (*AvatarSession) SetGateId added in v0.1.29

func (this *AvatarSession) SetGateId(id util.ID)

func (*AvatarSession) SetOnGateWayChanged added in v0.1.29

func (this *AvatarSession) SetOnGateWayChanged(f func(session *AvatarSession))

func (*AvatarSession) SetOnSessionClosed added in v0.1.29

func (this *AvatarSession) SetOnSessionClosed(f func())

func (*AvatarSession) StartAvatarSession added in v0.1.29

func (this *AvatarSession) StartAvatarSession()

func (*AvatarSession) StopAvatarSession added in v0.1.29

func (this *AvatarSession) StopAvatarSession()

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 {
	*Http
	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() error

func (*Center) Stop

func (this *Center) Stop() error

func (*Center) Unload

func (this *Center) Unload() error

type ClaimUser added in v0.1.29

type ClaimUser struct {
	Create time.Time
	Expire int64
	User   *User
}

func (*ClaimUser) GetUser added in v0.1.29

func (this *ClaimUser) GetUser() interface{}

func (*ClaimUser) Marshal added in v0.1.29

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

func (*ClaimUser) SetUser added in v0.1.29

func (this *ClaimUser) SetUser(user interface{})

func (*ClaimUser) Unmarshal added in v0.1.29

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

func (*ClaimUser) Valid added in v0.1.29

func (this *ClaimUser) Valid() error

type CommonRegistry

type CommonRegistry struct {
	Processes      map[util.ProcessId]*ProcessRegistry
	Services       map[string]map[uint16]*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(serviceType string, serviceId uint16)

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 ConsoleEvent added in v0.1.31

type ConsoleEvent struct {
	Text string
}

func NewConsoleEvent added in v0.1.31

func NewConsoleEvent(text string) *ConsoleEvent

func (*ConsoleEvent) GetId added in v0.1.31

func (this *ConsoleEvent) GetId() (protocol.BINARY_TAG, error)

func (*ConsoleEvent) Serializable added in v0.1.31

func (this *ConsoleEvent) Serializable() protocol.ISerializable

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) GetBool added in v0.1.43

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

func (*Context) GetFloat32 added in v0.1.43

func (this *Context) GetFloat32(key string) float32

func (*Context) GetFloat64 added in v0.1.43

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

func (*Context) GetIdType

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

func (*Context) GetInt added in v0.1.43

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

func (*Context) GetInt32 added in v0.1.43

func (this *Context) GetInt32(key string) int32

func (*Context) GetInt64 added in v0.1.43

func (this *Context) GetInt64(key string) int64

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 CreateAvatar added in v0.1.29

type CreateAvatar struct {
	Id int64
}

创建角色

func NewCreateAvatar added in v0.1.29

func NewCreateAvatar(id util.ID) *CreateAvatar

func (*CreateAvatar) GetId added in v0.1.29

func (this *CreateAvatar) GetId() (protocol.BINARY_TAG, error)

func (*CreateAvatar) Serializable added in v0.1.29

func (this *CreateAvatar) Serializable() protocol.ISerializable

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"`
	Host      string          `mapstructure:"host"`
	Port      string          `mapstructure:"port"`
	Version   string          `mapstructure:"version"`
	SName     string          `mapstructure:"serverName"`
	Name      string          `mapstructure:"name"`
	Etcd      EtcdConfig      `mapstructure:"-"`
	Mongo     MongoConfig     `mapstructure:"-"`
	Mysql     MysqlConfig     `mapstructure:"-"`
	Redis     RedisConfig     `mapstructure:"-"`
	Oss       OssConfig       `mapstructure:"-"`
	Mods      []lokas.IConfig `mapstructure:"-"`
	Modules   []string        `mapstructure:"modules"`
	DockerCLI DockerConfig    `mapstructure:"docker"`
}

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) GetDockerCLI added in v0.2.14

func (this *DefaultConfig) GetDockerCLI() 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) LoadInConfig added in v0.2.24

func (this *DefaultConfig) LoadInConfig() error

func (*DefaultConfig) MergeData added in v0.2.24

func (this *DefaultConfig) MergeData(in io.Reader) error

func (*DefaultConfig) ServerName

func (this *DefaultConfig) ServerName() string

type DockerConfig added in v0.2.14

type DockerConfig struct {
	Endpoint string
	CertPath string
}

type EtcdConfig

type EtcdConfig struct {
	EndPoints []string `mapstructure:"endpoints"`
	// contains filtered or unexported fields
}

type GameHandler added in v0.1.29

type GameHandler struct {
	Serializer   func(avatar lokas.IActor, process lokas.IProcess) error
	Initializer  func(avatar lokas.IActor, process lokas.IProcess) error
	Deserializer func(avatar lokas.IActor, process lokas.IProcess) error
	Updater      func(avatar lokas.IActor, process lokas.IProcess) error
	MsgDelegator func(avatar lokas.IActor, actorId util.ID, transId uint32, msg protocol.ISerializable) (protocol.ISerializable, error)
}

func (*GameHandler) GetDeserializer added in v0.1.29

func (this *GameHandler) GetDeserializer() func(avatar lokas.IActor, process lokas.IProcess) error

func (*GameHandler) GetInitializer added in v0.2.6

func (this *GameHandler) GetInitializer() func(avatar lokas.IActor, process lokas.IProcess) error

func (*GameHandler) GetMsgDelegator added in v0.1.29

func (this *GameHandler) GetMsgDelegator() func(avatar lokas.IActor, actorId util.ID, transId uint32, msg protocol.ISerializable) (protocol.ISerializable, error)

func (*GameHandler) GetSerializer added in v0.1.29

func (this *GameHandler) GetSerializer() func(avatar lokas.IActor, process lokas.IProcess) error

func (*GameHandler) GetUpdater added in v0.1.29

func (this *GameHandler) GetUpdater() func(avatar lokas.IActor, process lokas.IProcess) error

type Gate

type Gate struct {
	*Actor
	lokas.ISessionManager
	Host               string
	Port               string
	AuthFunc           func(data []byte) (interface{}, error)
	SessionCreatorFunc func(conn lokas.IConn) lokas.ISession
	Protocol           protocol.TYPE

	Ctx    context.Context
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

func (*Gate) GetServer added in v0.2.22

func (this *Gate) GetServer() lokas.Server

func (*Gate) Load

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

func (*Gate) LoadCustom added in v0.1.29

func (this *Gate) LoadCustom(host, port string, protocolType protocol.TYPE, connType ConnType) 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() error

func (*Gate) Stop

func (this *Gate) Stop() error

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() error

func (*Http) Stop

func (this *Http) Stop() error

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 KickAvatar added in v0.1.29

type KickAvatar struct {
	Id int64
}

func NewKickAvatar added in v0.1.29

func NewKickAvatar(id util.ID) *KickAvatar

func (*KickAvatar) GetId added in v0.1.29

func (this *KickAvatar) GetId() (protocol.BINARY_TAG, error)

func (*KickAvatar) Serializable added in v0.1.29

func (this *KickAvatar) Serializable() protocol.ISerializable

type LoginHandShake added in v0.1.29

type LoginHandShake struct {
	GameId   string
	Version  string
	ServerId int32
	UserId   util.ID
	AvatarId util.ID
	Token    string
}

func NewLoginHandShake added in v0.1.29

func NewLoginHandShake(gameId string, version string, serverId int32, userId util.ID, avatarId util.ID, token string) *LoginHandShake

func (*LoginHandShake) Marshal added in v0.1.29

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

func (*LoginHandShake) Unmarshal added in v0.1.29

func (this *LoginHandShake) Unmarshal(from []byte) error

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"`
	// contains filtered or unexported fields
}

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"`
	// contains filtered or unexported fields
}

type OssConfig added in v0.2.11

type OssConfig struct {
	OssType      string `mapstructure:"osstype"`
	EndPoint     string `mapstructure:"endpoint"`
	AccessId     string `mapstructure:"user"`
	AccessSecret string `mapstructure:"password"`
	// contains filtered or unexported fields
}

type PassiveSession added in v0.0.6

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

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

func NewPassiveSession added in v0.0.6

func NewPassiveSession(conn lokas.IConn, id util.ID, manager lokas.ISessionManager, opts ...PassiveSessionOption) *PassiveSession

func (*PassiveSession) GetConn added in v0.0.6

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

func (*PassiveSession) Load added in v0.0.6

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

func (*PassiveSession) OnClose added in v0.0.6

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

func (*PassiveSession) OnCreate added in v0.0.6

func (this *PassiveSession) OnCreate() error

func (*PassiveSession) OnDestroy added in v0.0.6

func (this *PassiveSession) OnDestroy() error

func (*PassiveSession) OnMessage added in v0.1.41

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

func (*PassiveSession) OnOpen added in v0.0.6

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

func (*PassiveSession) OnRecv added in v0.0.6

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

func (*PassiveSession) OnStart added in v0.0.6

func (this *PassiveSession) OnStart() error

func (*PassiveSession) OnStop added in v0.0.6

func (this *PassiveSession) OnStop() error

func (*PassiveSession) Start added in v0.0.6

func (this *PassiveSession) Start() error

func (*PassiveSession) StartMessagePump added in v0.0.6

func (this *PassiveSession) StartMessagePump()

func (*PassiveSession) Stop added in v0.0.6

func (this *PassiveSession) Stop() error

func (*PassiveSession) Unload added in v0.0.6

func (this *PassiveSession) Unload() error

type PassiveSessionOption added in v0.1.25

type PassiveSessionOption func(*PassiveSession)

type Process

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

func CreateProcess

func CreateProcess() *Process

func Instance added in v0.1.52

func Instance() *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) GetDocker added in v0.2.14

func (this *Process) GetDocker() (*dockerclient.Client, error)

func (*Process) GetEtcd

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

func (*Process) GetId added in v0.1.4

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

func (*Process) GetLogger

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

func (*Process) GetMongo

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

func (*Process) GetOss added in v0.2.11

func (this *Process) GetOss() *ossclient.Client

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) 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) PId added in v0.1.4

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

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) Type added in v0.1.4

func (this *Process) Type() string

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 {
	Host string
	Port string

	Sessions *ProxySessionManager
	// contains filtered or unexported fields
}

func NewProxy added in v0.1.25

func NewProxy(process lokas.IProcess) *Proxy

func (*Proxy) GetProcess added in v0.1.25

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

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) Send added in v0.1.25

func (this *Proxy) Send(id util.ProcessId, msg *protocol.RouteMessage) error

func (*Proxy) SendData added in v0.3.6

func (this *Proxy) SendData(pid util.ProcessId, data []byte) error

func (*Proxy) SetPort added in v0.1.25

func (this *Proxy) SetPort(p string)

func (*Proxy) SetProcess added in v0.1.25

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

func (*Proxy) Start

func (this *Proxy) Start() error

func (*Proxy) Stop

func (this *Proxy) Stop() error

func (*Proxy) Type

func (this *Proxy) Type() string

func (*Proxy) Unload

func (this *Proxy) Unload() error

type ProxySession added in v0.1.26

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

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

func NewProxySession added in v0.1.26

func NewProxySession(conn lokas.IConn, id util.ID, manager *ProxySessionManager, passive bool, opts ...SessionOption) *ProxySession

func (*ProxySession) GetConn added in v0.1.26

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

func (*ProxySession) GetProcess added in v0.1.26

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

func (*ProxySession) HandleMessage added in v0.1.26

func (this *ProxySession) HandleMessage(f func(msg *protocol.BinaryMessage))

func (*ProxySession) OnClose added in v0.1.26

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

func (*ProxySession) OnCreate added in v0.1.26

func (this *ProxySession) OnCreate() error

func (*ProxySession) OnDestroy added in v0.1.26

func (this *ProxySession) OnDestroy() error

func (*ProxySession) OnOpen added in v0.1.26

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

func (*ProxySession) OnRecv added in v0.1.26

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

func (*ProxySession) SendMessage added in v0.1.26

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

func (*ProxySession) SetProcess added in v0.1.26

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

func (*ProxySession) Start added in v0.1.26

func (this *ProxySession) Start() error

func (*ProxySession) Stop added in v0.1.26

func (this *ProxySession) Stop() error

func (*ProxySession) Type added in v0.1.26

func (this *ProxySession) Type() string

func (*ProxySession) Update added in v0.1.26

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

func (*ProxySession) Write added in v0.1.26

func (this *ProxySession) Write(data []byte) error

type ProxySessionManager added in v0.1.26

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

func NewProxySessionManager added in v0.1.26

func NewProxySessionManager(safeMode bool) *ProxySessionManager

func (*ProxySessionManager) AddSession added in v0.1.26

func (this *ProxySessionManager) AddSession(id util.ID, session lokas.ISession)

func (*ProxySessionManager) Clear added in v0.1.26

func (this *ProxySessionManager) Clear()

func (*ProxySessionManager) GetRoundSession added in v0.1.26

func (this *ProxySessionManager) GetRoundSession() (lokas.ISession, bool)

func (*ProxySessionManager) GetSession added in v0.1.26

func (this *ProxySessionManager) GetSession(id util.ID) lokas.ISession

func (*ProxySessionManager) GetSessionCount added in v0.1.26

func (this *ProxySessionManager) GetSessionCount() int

func (*ProxySessionManager) Range added in v0.1.26

func (this *ProxySessionManager) Range(f func(id util.ID, session lokas.ISession) bool)

func (*ProxySessionManager) RemoveSession added in v0.1.26

func (this *ProxySessionManager) RemoveSession(id util.ID)

func (*ProxySessionManager) ResetSession added in v0.1.26

func (this *ProxySessionManager) ResetSession(id util.ID, session lokas.ISession)

type RedisConfig

type RedisConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Password string `mapstructure:"password"`
	// contains filtered or unexported fields
}

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) GetLeaseId added in v0.1.25

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

return leaseId,(bool)is registered,error

func (*Registry) GetProcess

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

func (*Registry) GetProcessIdByActor

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

func (*Registry) GetProcessInfo added in v0.1.25

func (this *Registry) GetProcessInfo() string

func (*Registry) GetServiceDiscoverMgr added in v0.2.30

func (reg *Registry) GetServiceDiscoverMgr() lokas.IServiceDiscoverMgr

func (*Registry) GetServiceRegisterMgr added in v0.2.24

func (reg *Registry) GetServiceRegisterMgr() lokas.IServiceRegisterMgr

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) SetProcess

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

func (*Registry) Start

func (this *Registry) Start() error

func (*Registry) Stop

func (this *Registry) Stop() error

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

type Response added in v0.1.29

type Response struct {
	OK bool
}

默认回复

func NewResponse added in v0.1.29

func NewResponse(v bool) *Response

func (*Response) GetId added in v0.1.29

func (this *Response) GetId() (protocol.BINARY_TAG, error)

func (*Response) Serializable added in v0.1.29

func (this *Response) Serializable() protocol.ISerializable

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) RouteDataByService added in v0.3.6

func (router *Router) RouteDataByService(dataMsg *protocol.RouteDataMsg, serviceType string, serviceId uint16, lineId uint16) error

func (*Router) RouteDataMsgLocal added in v0.3.9

func (router *Router) RouteDataMsgLocal(dataMsg *protocol.RouteDataMsg) error

func (*Router) RouteMsg

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

func (*Router) RouteMsgLocal added in v0.2.35

func (router *Router) RouteMsgLocal(msg *protocol.RouteMessage) error

func (*Router) RouteMsgToService added in v0.3.6

func (router *Router) RouteMsgToService(fromActorId util.ID, serviceType string, serviceId uint16, lineId uint16, transId uint32, reqType uint8, msg protocol.ISerializable, protocolType protocol.TYPE) error

func (*Router) RouteMsgWithPid added in v0.3.6

func (router *Router) RouteMsgWithPid(routeMsg *protocol.RouteMessage, pid util.ProcessId) error

func (*Router) SetProcess

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

func (*Router) Start

func (this *Router) Start() error

func (*Router) Stop

func (this *Router) Stop() error

func (*Router) Type

func (this *Router) Type() string

func (*Router) Unload

func (this *Router) Unload() error

type ServiceDiscoverMgr added in v0.2.30

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

func NewServiceDiscoverMgr added in v0.2.30

func NewServiceDiscoverMgr(process lokas.IProcess) *ServiceDiscoverMgr

func (*ServiceDiscoverMgr) FindRandServiceInfo added in v0.3.6

func (mgr *ServiceDiscoverMgr) FindRandServiceInfo(serviceType string, serviceId uint16, lineId uint16) (*lokas.ServiceInfo, bool)

if serviceId is zero,get random serviceId; if lineId is zero,get randmo lineId

func (*ServiceDiscoverMgr) FindServiceInfo added in v0.2.30

func (mgr *ServiceDiscoverMgr) FindServiceInfo(serviceType string, serviceId uint16, lineId uint16) (*lokas.ServiceInfo, bool)

func (*ServiceDiscoverMgr) StartDiscover added in v0.2.30

func (mgr *ServiceDiscoverMgr) StartDiscover() error

func (*ServiceDiscoverMgr) Stop added in v0.2.30

func (mgr *ServiceDiscoverMgr) Stop()

type ServiceRegister added in v0.2.21

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

type ServiceRegisterMgr added in v0.2.21

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

func NewServiceRegisterMgr added in v0.2.21

func NewServiceRegisterMgr(process lokas.IProcess) *ServiceRegisterMgr

func (*ServiceRegisterMgr) FindServiceInfo added in v0.2.24

func (mgr *ServiceRegisterMgr) FindServiceInfo(serviceType string, serviceId uint16, lineId uint16) (*lokas.ServiceInfo, bool)

func (*ServiceRegisterMgr) FindServiceList added in v0.2.24

func (mgr *ServiceRegisterMgr) FindServiceList(serviceType string) ([]*lokas.ServiceInfo, bool)

func (*ServiceRegisterMgr) Register added in v0.2.21

func (mgr *ServiceRegisterMgr) Register(info *lokas.ServiceInfo) error

func (*ServiceRegisterMgr) Stop added in v0.2.22

func (mgr *ServiceRegisterMgr) Stop()

func (*ServiceRegisterMgr) Unregister added in v0.2.21

func (mgr *ServiceRegisterMgr) Unregister(serviceType string, serviceId uint16, lineId uint16) error

func (*ServiceRegisterMgr) UpdateServiceInfo added in v0.2.21

func (mgr *ServiceRegisterMgr) UpdateServiceInfo(info *lokas.ServiceInfo) error

type ServiceRegistry

type ServiceRegistry struct {
	// Id          uint32
	ServiceType string
	ServiceId   uint16
	// GameId      string
	Host      string
	Port      uint32
	Version   string
	Cnt       uint32
	ProcessId util.ProcessId
	CreateAt  time.Time
}

service

func NewServiceRegistry added in v0.2.20

func NewServiceRegistry(serviceType string, serviceId uint16) *ServiceRegistry

type SessionOption

type SessionOption func(*ProxySession)

func WithCloseFunc

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

func WithMsgHandler added in v0.1.26

func WithMsgHandler(msgHandler func(msg *protocol.BinaryMessage)) SessionOption

func WithOpenFunc

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

type Stat added in v0.3.27

type Stat struct {
	*Http

	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Stat) GetStatus added in v0.3.27

func (this *Stat) GetStatus(key string) string

func (*Stat) Load added in v0.3.27

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

func (*Stat) OnStart added in v0.3.27

func (this *Stat) OnStart() error

func (*Stat) OnStop added in v0.3.27

func (this *Stat) OnStop() error

func (*Stat) SetStatus added in v0.3.27

func (this *Stat) SetStatus(key string, value string)

func (*Stat) Type added in v0.3.27

func (this *Stat) Type() string

func (*Stat) Unload added in v0.3.27

func (this *Stat) Unload() error

type TcpClient added in v0.0.6

type TcpClient struct {
	events.EventEmmiter
	*ActiveSession

	Closing  bool
	Opening  bool
	ConnType ConnType
	Protocol protocol.TYPE
	// contains filtered or unexported fields
}

func NewTcpClient added in v0.0.6

func NewTcpClient() *TcpClient

func (*TcpClient) Call added in v0.0.6

func (this *TcpClient) Call(transId uint32, req interface{}) (interface{}, error)

func (*TcpClient) ClearContext added in v0.0.6

func (this *TcpClient) ClearContext(err error)

func (*TcpClient) Connect added in v0.0.6

func (this *TcpClient) Connect(addr string) *promise.Promise[interface{}]

func (*TcpClient) Connected added in v0.0.6

func (this *TcpClient) Connected() bool

func (*TcpClient) Disconnect added in v0.0.6

func (this *TcpClient) Disconnect(b bool) *promise.Promise[interface{}]

func (*TcpClient) GetContext added in v0.0.8

func (this *TcpClient) GetContext(transId uint32) lokas.IReqContext

func (*TcpClient) MessageHandler added in v0.0.6

func (this *TcpClient) MessageHandler(msg *protocol.BinaryMessage)

func (*TcpClient) Off added in v0.0.6

func (this *TcpClient) Off(cmdId uint16, listener events.Listener)

func (*TcpClient) OnClose added in v0.0.6

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

func (*TcpClient) OnMessage added in v0.0.6

func (this *TcpClient) OnMessage(cmdId protocol.BINARY_TAG, listeners ...events.Listener)

func (*TcpClient) OnOpen added in v0.0.6

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

func (*TcpClient) OnRecvCmd added in v0.0.6

func (this *TcpClient) OnRecvCmd(cmdId protocol.BINARY_TAG, time time.Duration) *promise.Promise[interface{}]

func (*TcpClient) Request added in v0.0.6

func (this *TcpClient) Request(req interface{}) *promise.Promise[interface{}]

func (*TcpClient) SendMessage added in v0.0.6

func (this *TcpClient) SendMessage(transId uint32, msg interface{})

func (*TcpClient) SetMessageHandler added in v0.1.35

func (this *TcpClient) SetMessageHandler(handler func(msg *protocol.BinaryMessage))

func (*TcpClient) SetProtocol added in v0.1.35

func (this *TcpClient) SetProtocol(p protocol.TYPE)

type User

type User struct {
	Id           util.ID `bson:"_id"`
	Role         uint32
	Avatars      map[string]util.ID
	AgentsParams map[string]string
	Token        string
	RefreshToken string
	UserName     string
	Password     string
}

func (*User) Deserialize added in v0.1.29

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

func (*User) GetId added in v0.1.29

func (this *User) GetId() util.ID

func (*User) GetServerInfo added in v0.1.29

func (this *User) GetServerInfo(s string) (string, int32)

func (*User) HasAvatarById added in v0.1.29

func (this *User) HasAvatarById(id util.ID) bool

func (*User) HasAvatarByServer added in v0.1.29

func (this *User) HasAvatarByServer(gameId string, serverId int32) (bool, util.ID)

func (*User) Initialize added in v0.2.7

func (this *User) Initialize(a lokas.IProcess) error

func (*User) Serialize added in v0.1.29

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

func (*User) SimpleUser added in v0.1.29

func (this *User) SimpleUser() *User

type UserCreator

type UserCreator func() interface{}

type WsClient added in v0.1.35

type WsClient struct {
	events.EventEmmiter

	Closing    bool
	Opening    bool
	Protocol   protocol.TYPE
	MsgHandler func(msg *protocol.BinaryMessage)
	// contains filtered or unexported fields
}

func NewWsClient added in v0.1.35

func NewWsClient() *WsClient

func (*WsClient) AsyncCall added in v0.1.35

func (this *WsClient) AsyncCall(transId uint32, req interface{}) (interface{}, error)

func (*WsClient) Call added in v0.1.35

func (this *WsClient) Call(transId uint32, req interface{}) (interface{}, error)

func (*WsClient) ClearContext added in v0.1.35

func (this *WsClient) ClearContext()

func (*WsClient) Close added in v0.1.35

func (this *WsClient) Close() *promise.Promise[interface{}]

func (*WsClient) Connect added in v0.1.35

func (this *WsClient) Connect(addr string) *promise.Promise[interface{}]

func (*WsClient) Connected added in v0.1.35

func (this *WsClient) Connected() bool

func (*WsClient) Disconnect added in v0.1.35

func (this *WsClient) Disconnect(force bool) *promise.Promise[interface{}]

func (*WsClient) GetContext added in v0.1.35

func (this *WsClient) GetContext(transId uint32) lokas.IReqContext

func (*WsClient) MessageHandler added in v0.1.35

func (this *WsClient) MessageHandler(msg *protocol.BinaryMessage)

func (*WsClient) Off added in v0.1.35

func (this *WsClient) Off(cmdId uint16, listener events.Listener)

func (*WsClient) OnClose added in v0.1.35

func (this *WsClient) OnClose(conn *websocket.Conn)

func (*WsClient) OnMessage added in v0.1.35

func (this *WsClient) OnMessage(cmdId protocol.BINARY_TAG, listeners ...events.Listener)

func (*WsClient) OnOpen added in v0.1.35

func (this *WsClient) OnOpen(conn *websocket.Conn)

func (*WsClient) OnRecv added in v0.1.35

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

func (*WsClient) OnRecvCmd added in v0.1.35

func (this *WsClient) OnRecvCmd(cmdId protocol.BINARY_TAG, time time.Duration) *promise.Promise[interface{}]

func (*WsClient) OnRecvMessage added in v0.1.35

func (this *WsClient) OnRecvMessage(cmdId protocol.BINARY_TAG, transId uint32, msg interface{})

func (*WsClient) Open added in v0.1.35

func (this *WsClient) Open() *promise.Promise[interface{}]

func (*WsClient) Request added in v0.1.35

func (this *WsClient) Request(req interface{}) *promise.Promise[interface{}]

func (*WsClient) Run added in v0.1.35

func (this *WsClient) Run()

func (*WsClient) SendMessage added in v0.1.35

func (this *WsClient) SendMessage(transId uint32, msg interface{})

func (*WsClient) SetMessageHandler added in v0.1.35

func (this *WsClient) SetMessageHandler(handler func(msg *protocol.BinaryMessage))

func (*WsClient) SetProtocol added in v0.1.35

func (this *WsClient) SetProtocol(p protocol.TYPE)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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