Documentation ¶
Index ¶
- Variables
- func EnableDebug()
- func Invoke(fn func())
- func Listen(addr string, opts ...Option)
- func ListenWS(addr string, opts ...Option)
- func Register(c component.Component, options ...component.Option)
- func SetCheckOriginFunc(fn func(*http.Request) bool)
- func SetDictionary(dict map[string]uint16)
- func SetHeartbeatInterval(d time.Duration)
- func SetLogger(l Logger)
- func SetSerializer(seri serialize.Serializer)
- func SetWSPath(path string)
- func Shutdown()
- type ApiManager
- type ApiManagerOpts
- type ApiServer
- type ApiServerOpts
- type GameManager
- func (g *GameManager) AfterInit()
- func (g *GameManager) BeforeShutdown()
- func (g *GameManager) EnterToGame(uid int, serverdata *game.ServerData, ...) error
- func (g *GameManager) GetCenterServerByBalance(ngid int) *game.GameServer
- func (g *GameManager) GetCenterServers(ngid int, ngc func(s *game.GameServer) bool) map[string]*game.GameServer
- func (g *GameManager) GetGameListState() map[string]interface{}
- func (g *GameManager) GetServerByGSID(gsid string) *game.GameServer
- func (g *GameManager) GetServerSort() map[string]*game.GameServer
- func (g *GameManager) GetTable(gsidtid string) *game.GameTable
- func (g *GameManager) HandleMsg(msg *nats.Msg)
- func (g *GameManager) Init()
- func (g *GameManager) InitNats()
- func (g *GameManager) ProcessServer(route string, body reflect.Value)
- func (g *GameManager) ReconnectToGame(uid int, connectServerdata *game.ServerData) (*game.ServerData, error)
- func (g *GameManager) RegisterServer(gsid string, server *game.GameServer)
- func (g *GameManager) RegisterTable(gsidtid string, table *game.GameTable)
- func (g *GameManager) RemoveServerByGSID(gsid string)
- func (g *GameManager) ServerMaintence()
- func (g *GameManager) Shutdown()
- type GameManagerOpts
- type Logger
- type Message
- type Option
- type Pipeline
- type PipelineChannel
- type PipelineFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBrokenPipe represents the low-level connection has broken. ErrBrokenPipe = errors.New("broken low-level pipe") // ErrBufferExceed indicates that the current session buffer is full and // can not receive more data. ErrBufferExceed = errors.New("session send buffer exceed") )
var ( ResponseSuccess = []byte("SUCCESS") ResponseFail = []byte("FAIL") )
var ( ErrSessionOnNotify = errors.New("current session working on notify mode") ErrCloseClosedConnector = errors.New("close closed connector") ErrClosedConnector = errors.New("connector closed") ErrMemberNotFound = errors.New("member not found in the connector") ErrCloseClosedSession = errors.New("close closed session") ErrSessionDuplication = errors.New("session has existed in the current connector") )
Errors that could be occurred during message handling.
var VERSION = "0.0.1"
VERSION returns current nano version
Functions ¶
func Listen ¶
Listen listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections.
func ListenWS ¶
ListenWS listens on the TCP network address addr and then upgrades the HTTP server connection to the WebSocket protocol to handle requests on incoming connections.
func SetCheckOriginFunc ¶
SetCheckOriginFunc set the function that check `Origin` in http headers
func SetDictionary ¶
SetDictionary set routes map, TODO(warning): set dictionary in runtime would be a dangerous operation!!!!!!
func SetHeartbeatInterval ¶
SetHeartbeatInterval set heartbeat time interval
func SetSerializer ¶
func SetSerializer(seri serialize.Serializer)
SetSerializer customize application serializer, which automatically Marshal and UnMarshal handler payload
Types ¶
type ApiManager ¶ added in v0.4.3
type ApiManager struct {
// contains filtered or unexported fields
}
var ( ApiManagerHandler *ApiManager DefautApiAddrs = "127.0.0.1:20066" )
func NewApiManager ¶ added in v0.4.3
func NewApiManager(opts ...ApiManagerOpts) *ApiManager
func (*ApiManager) AfterInit ¶ added in v0.4.3
func (am *ApiManager) AfterInit()
func (*ApiManager) BeforeShutdown ¶ added in v0.4.3
func (am *ApiManager) BeforeShutdown()
func (*ApiManager) Init ¶ added in v0.4.3
func (am *ApiManager) Init()
func (*ApiManager) Shutdown ¶ added in v0.4.3
func (am *ApiManager) Shutdown()
type ApiManagerOpts ¶ added in v0.4.3
type ApiManagerOpts func(am *ApiManager)
func WithApiAddrs ¶ added in v0.4.3
func WithApiAddrs(addrs string) ApiManagerOpts
type ApiServer ¶ added in v0.4.3
type ApiServer struct { ReadEndStr []byte // contains filtered or unexported fields }
func NewApiServer ¶ added in v0.4.3
func NewApiServer(conn net.Conn, opts ...ApiServerOpts) *ApiServer
type ApiServerOpts ¶ added in v0.4.3
type ApiServerOpts func(as *ApiServer)
type GameManager ¶ added in v0.4.3
type GameManager struct { Serversort map[string]*game.GameServer Alltablesort map[string]*game.GameTable // contains filtered or unexported fields }
var ( GMHander *GameManager DefautListenGame = "0.0.0.0:20572" )
func NewGameManager ¶ added in v0.4.3
func NewGameManager(opts ...GameManagerOpts) *GameManager
func (*GameManager) AfterInit ¶ added in v0.4.3
func (g *GameManager) AfterInit()
func (*GameManager) BeforeShutdown ¶ added in v0.4.3
func (g *GameManager) BeforeShutdown()
func (*GameManager) EnterToGame ¶ added in v0.4.3
func (g *GameManager) EnterToGame(uid int, serverdata *game.ServerData, cb func(result *game.ControlUserEnterroom), isretry bool) error
func (*GameManager) GetCenterServerByBalance ¶ added in v0.4.3
func (g *GameManager) GetCenterServerByBalance(ngid int) *game.GameServer
func (*GameManager) GetCenterServers ¶ added in v0.4.3
func (g *GameManager) GetCenterServers(ngid int, ngc func(s *game.GameServer) bool) map[string]*game.GameServer
func (*GameManager) GetGameListState ¶ added in v0.4.3
func (g *GameManager) GetGameListState() map[string]interface{}
func (*GameManager) GetServerByGSID ¶ added in v0.4.3
func (g *GameManager) GetServerByGSID(gsid string) *game.GameServer
func (*GameManager) GetServerSort ¶ added in v0.4.3
func (g *GameManager) GetServerSort() map[string]*game.GameServer
func (*GameManager) GetTable ¶ added in v0.4.3
func (g *GameManager) GetTable(gsidtid string) *game.GameTable
func (*GameManager) HandleMsg ¶ added in v0.4.4
func (g *GameManager) HandleMsg(msg *nats.Msg)
func (*GameManager) Init ¶ added in v0.4.3
func (g *GameManager) Init()
func (*GameManager) InitNats ¶ added in v0.4.4
func (g *GameManager) InitNats()
func (*GameManager) ProcessServer ¶ added in v0.4.3
func (g *GameManager) ProcessServer(route string, body reflect.Value)
func (*GameManager) ReconnectToGame ¶ added in v0.4.3
func (g *GameManager) ReconnectToGame(uid int, connectServerdata *game.ServerData) (*game.ServerData, error)
func (*GameManager) RegisterServer ¶ added in v0.4.3
func (g *GameManager) RegisterServer(gsid string, server *game.GameServer)
func (*GameManager) RegisterTable ¶ added in v0.4.3
func (g *GameManager) RegisterTable(gsidtid string, table *game.GameTable)
func (*GameManager) RemoveServerByGSID ¶ added in v0.4.3
func (g *GameManager) RemoveServerByGSID(gsid string)
func (*GameManager) ServerMaintence ¶ added in v0.4.4
func (g *GameManager) ServerMaintence()
func (*GameManager) Shutdown ¶ added in v0.4.3
func (g *GameManager) Shutdown()
type GameManagerOpts ¶ added in v0.4.3
type GameManagerOpts func(g *GameManager)
func WithGameManagerAddrs ¶ added in v0.4.3
func WithGameManagerAddrs(addrs string) GameManagerOpts
type Logger ¶
type Logger interface { Println(v ...interface{}) Fatal(v ...interface{}) Printf(format string, v ...interface{}) }
Logger represents the log interface
type Pipeline ¶
type Pipeline interface { Outbound() PipelineChannel Inbound() PipelineChannel }
func NewPipeline ¶
func NewPipeline() Pipeline
type PipelineChannel ¶
type PipelineChannel interface { PushFront(h PipelineFunc) PushBack(h PipelineFunc) Process(s *session.Session, msg Message) error }