Documentation ¶
Index ¶
- type AppContext
- type BaseComponent
- type FrontendId
- type IAppContext
- type IApplication
- type IComponent
- type IConnectListener
- type IConnector
- type IEvent
- type IHandler
- type INetworkEntity
- type INode
- type IRoute
- type ISession
- type MessageListener
- type NodeMap
- type Packet
- type PacketDecoder
- type PacketEncoder
- type RouteFunc
- type RouteFunction
- type RpcFilter
- type RpcFilterFunc
- type RpcMessage
- type RpcNodeInfo
- type SID
- type Serializer
- type SessionListener
- type UID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppContext ¶
type AppContext struct {
// contains filtered or unexported fields
}
func (*AppContext) App ¶
func (b *AppContext) App() IApplication
func (*AppContext) Set ¶
func (b *AppContext) Set(ctx IApplication)
type BaseComponent ¶
type BaseComponent struct {
AppContext
}
BaseComponent
func (*BaseComponent) AfterInit ¶
func (*BaseComponent) AfterInit()
func (*BaseComponent) BeforeStop ¶
func (*BaseComponent) BeforeStop()
func (*BaseComponent) Init ¶
func (*BaseComponent) Init()
func (*BaseComponent) Name ¶
func (*BaseComponent) Name() string
func (*BaseComponent) Stop ¶
func (*BaseComponent) Stop()
type FrontendId ¶
type FrontendId = string
type IAppContext ¶
type IAppContext interface { Set(ctx IApplication) App() IApplication }
type IApplication ¶
type IApplication interface { //NodeId current nodeId NodeId() string //NodeType current nodeType NodeType() string //ThisNode current node info ThisNode() INode //Register load component Register(components ...IComponent) //Find get component Find(name string) IComponent //Remove remove a component Remove(name string) IComponent //All all components All() []IComponent //PostEvent PostEvent(e IEvent) //OnShutdown execute this func before the application shutdown OnShutdown(shutdownFunc ...func()) //Startup Startup(startupFunc ...func()) }
type IComponent ¶
type IComponent interface { IAppContext //Name unique components name Name() string Init() AfterInit() BeforeStop() Stop() }
IComponent
type IConnectListener ¶
type IConnector ¶
type IConnector interface { Start() OnConnect(listener IConnectListener) Stop() }
type IHandler ¶
type IHandler interface { IAppContext Name() string SetName(name string) PreInit() Init() }
type INetworkEntity ¶
type ISession ¶
type ISession interface { SID() SID UID() UID FrontendId() FrontendId SetStatus(status int) Status() int Data() map[string]interface{} Remove(key string) Set(key string, value interface{}) Contains(key string) bool Conn() net.Conn OnClose(listener SessionListener) OnError(listener SessionListener) OnMessage(listener MessageListener) Send(msg []byte) error SendBatch(batchMsg ...[]byte) Closed() }
type MessageListener ¶
type PacketDecoder ¶
type RouteFunc ¶
type RouteFunc func(session ISession, msg RpcMessage, nodeInfo []RpcNodeInfo)
type RouteFunction ¶
type RouteFunction func(session ISession, packet interface{}, ctx IApplication) error
type RpcFilter ¶
type RpcFilter struct { Name string Before RpcFilterFunc After RpcFilterFunc }
type RpcFilterFunc ¶
type RpcFilterFunc func(nodeId string, msg interface{})
type RpcMessage ¶
type RpcMessage struct {
// contains filtered or unexported fields
}
type RpcNodeInfo ¶
type Serializer ¶
type Serializer interface { Marshal(interface{}) ([]byte, error) Unmarshal([]byte, interface{}) error Name() string }
Serializer 消息序列化
type SessionListener ¶
type SessionListener func(session ISession)
Click to show internal directories.
Click to hide internal directories.