Documentation
¶
Index ¶
- type AppContext
- type BaseComponent
- type EventFn
- type FrontendId
- type IAppContext
- type IApplication
- type IComponent
- type IConnectListener
- type IConnector
- type IEvent
- type IHandler
- type INetworkEntity
- type INode
- type IRoute
- type ISerializer
- type ISession
- type InvokeFn
- type MessageListener
- type Packet
- type PacketDecoder
- type PacketEncoder
- type RouteFunc
- type RouteFunction
- type RpcFilter
- type RpcFilterFunc
- type RpcMessage
- type RpcNodeInfo
- type SID
- 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
//Running is running
Running() bool
//Find find a component
Find(name string) IComponent
//Remove remove a component
Remove(name string) IComponent
//All all components
All() []IComponent
//Startup
Startup(components ...IComponent)
//Shutdown
Shutdown(beforeStopHook ...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()
AfterInit()
GetEvents() map[string][]EventFn
GetEvent(name string) ([]EventFn, bool)
GetLocals() map[string]*InvokeFn
GetLocal(funcName string) (*InvokeFn, bool)
GetRemotes() map[string]*InvokeFn
GetRemote(funcName string) (*InvokeFn, bool)
PutMessage(message interface{})
Stop()
}
type INetworkEntity ¶
type ISerializer ¶
type ISerializer interface {
Marshal(interface{}) ([]byte, error)
Unmarshal([]byte, interface{}) error
Name() string
}
ISerializer 消息序列化
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 SessionListener ¶
type SessionListener func(session ISession)
Click to show internal directories.
Click to hide internal directories.