Documentation ¶
Index ¶
- type Command
- type CommandLowerCase
- type CommandManager
- type CommandObject
- type CommandProcessor
- type Configurer
- func (c *Configurer) GetRPCClientByIndex(index int) (rpcClientConf, error)
- func (c *Configurer) GetRPCClientByName(name string) (rpcClientConf, error)
- func (c *Configurer) GetRPCClients() []rpcClientConf
- func (c *Configurer) HttpClientAddress() (addr, port string)
- func (c *Configurer) HttpClientHandshakeTimeoutSecond() int
- func (c *Configurer) HttpClientRequestTimeoutSecond() int
- func (c *Configurer) HttpClientTCPConnectTimeoutSecond() int
- func (c *Configurer) HttpServerAddress() (addr, port string)
- func (c *Configurer) HttpServerIdleTimeout() time.Duration
- func (c *Configurer) HttpServerMaxHeaderBytes() int
- func (c *Configurer) HttpServerReadTimeout() time.Duration
- func (c *Configurer) HttpServerWriteTimeout() time.Duration
- func (c *Configurer) RPCServerAddress() (addr, port string)
- func (c *Configurer) SetWebSocketServerDefaultAESKey(key []byte)
- func (c *Configurer) WebSocketServerAcceptTimeoutSecond() int
- func (c *Configurer) WebSocketServerAddress() (addr, port string)
- func (c *Configurer) WebSocketServerAliveTimeoutSecond() int
- func (c *Configurer) WebSocketServerConnectionCapacity() int
- func (c *Configurer) WebSocketServerConnectionLostChanCapacity() int
- func (c *Configurer) WebSocketServerDefaultAESKey() []byte
- func (c *Configurer) WebSocketServerDefaultAESKeyString() string
- func (c *Configurer) WebSocketServerPacketChanCapacity() int
- type HallManager
- type MiddleHandler
- type Nex
- type PacketHandler
- type RoomManager
- type UpdateManager
- type UpdateObject
- type UpdateProcessor
- type UserManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandLowerCase ¶
type CommandLowerCase struct { //Code is success code, you can defined yoursef Code int `json:"code"` //Command is string command name, Command string `json:"command"` //Step is a serial number you can use to check command sequence Step int `json:"step"` //Data is real data which is string format, you can define the content Data string `json:"data"` }
type CommandManager ¶
type CommandManager interface { RunProcessor(object *CommandObject) error RegisterProcessor(cmdName string, p CommandProcessor) error UnRegisterProcessor(cmdName string) CreateCommand(code int, step int, cmdName string, data string) (*Command, error) }
func NewCommandManager ¶
func NewCommandManager() (CommandManager, error)
type CommandObject ¶
ProcessorObject is a container contains command and user (send this command)
type CommandProcessor ¶
type CommandProcessor interface {
Run(obj *CommandObject) error
}
CommandProcessor is a interface user implements this interface to create command processor and register the processor to nex when command received , processor will be executed
type Configurer ¶
type Configurer struct {
// contains filtered or unexported fields
}
Config config main struct
func NewConfigurer ¶
func NewConfigurer(filePath string) (*Configurer, error)
NewConfig make a new config struct
func (*Configurer) GetRPCClientByIndex ¶
func (c *Configurer) GetRPCClientByIndex(index int) (rpcClientConf, error)
func (*Configurer) GetRPCClientByName ¶
func (c *Configurer) GetRPCClientByName(name string) (rpcClientConf, error)
func (*Configurer) HttpClientAddress ¶
func (c *Configurer) HttpClientAddress() (addr, port string)
func (*Configurer) HttpClientHandshakeTimeoutSecond ¶
func (c *Configurer) HttpClientHandshakeTimeoutSecond() int
func (*Configurer) HttpClientRequestTimeoutSecond ¶
func (c *Configurer) HttpClientRequestTimeoutSecond() int
func (*Configurer) HttpClientTCPConnectTimeoutSecond ¶
func (c *Configurer) HttpClientTCPConnectTimeoutSecond() int
func (*Configurer) HttpServerAddress ¶
func (c *Configurer) HttpServerAddress() (addr, port string)
http
func (*Configurer) HttpServerIdleTimeout ¶
func (c *Configurer) HttpServerIdleTimeout() time.Duration
func (*Configurer) HttpServerMaxHeaderBytes ¶
func (c *Configurer) HttpServerMaxHeaderBytes() int
func (*Configurer) HttpServerReadTimeout ¶
func (c *Configurer) HttpServerReadTimeout() time.Duration
func (*Configurer) HttpServerWriteTimeout ¶
func (c *Configurer) HttpServerWriteTimeout() time.Duration
func (*Configurer) RPCServerAddress ¶
func (c *Configurer) RPCServerAddress() (addr, port string)
rpc server
func (*Configurer) SetWebSocketServerDefaultAESKey ¶
func (c *Configurer) SetWebSocketServerDefaultAESKey(key []byte)
func (*Configurer) WebSocketServerAcceptTimeoutSecond ¶
func (c *Configurer) WebSocketServerAcceptTimeoutSecond() int
func (*Configurer) WebSocketServerAddress ¶
func (c *Configurer) WebSocketServerAddress() (addr, port string)
websocket
func (*Configurer) WebSocketServerAliveTimeoutSecond ¶
func (c *Configurer) WebSocketServerAliveTimeoutSecond() int
func (*Configurer) WebSocketServerConnectionCapacity ¶
func (c *Configurer) WebSocketServerConnectionCapacity() int
func (*Configurer) WebSocketServerConnectionLostChanCapacity ¶
func (c *Configurer) WebSocketServerConnectionLostChanCapacity() int
func (*Configurer) WebSocketServerDefaultAESKey ¶
func (c *Configurer) WebSocketServerDefaultAESKey() []byte
func (*Configurer) WebSocketServerDefaultAESKeyString ¶
func (c *Configurer) WebSocketServerDefaultAESKeyString() string
func (*Configurer) WebSocketServerPacketChanCapacity ¶
func (c *Configurer) WebSocketServerPacketChanCapacity() int
type HallManager ¶
type HallManager interface { CreateHall(hallID int, name string) (entity.Hall, error) RemoveHall(hallID int) GetHall(hallID int) (entity.Hall, bool) GetHalls() []entity.Hall ContainHall(hallID int) bool }
func NewHallManager ¶
func NewHallManager() (HallManager, error)
type MiddleHandler ¶
type MiddleHandler interface { PacketToCommand(packet []byte) (*Command, error) CommandToPacket(cmd *Command) ([]byte, error) CommandToPacketLowercase(cmd *CommandLowerCase) ([]byte, error) }
func NewMiddleHandler ¶
func NewMiddleHandler() (MiddleHandler, error)
type Nex ¶
type Nex interface { Start() Stop() Version() string GetConfig() *Configurer //RegisterCommandProcessor registers a process to handle command RegisterCommandProcessor(name string, p CommandProcessor) error CreateCommand(code int, step int, cmdName string, data string) (*Command, error) SendCommand(cmd *Command, sender entity.User, targetConnIDs []string, lowercase bool) //RegisterBuiltinEventProcessor registers a procese to handle event RegisterBuiltinEventProcessor(code builtinEvent.EventNO, p builtinEvent.EventProcessor) error UnRegisterBuiltinEventProcessor(code builtinEvent.EventNO) //RegisterBuiltinEventProcessor registers a procese to handle event RegisterEventProcessor(event string, p event.EventProcessor) error UnRegisterEventProcessor(event string) DispatchEvent(event string) //RegisterUpdateProcessor RegisterUpdateProcessor(name string, p UpdateProcessor) error UnRegisterUpdateProcessor(name string) error StartUpdateProcessor(name string) (resErr error) StopUpdateProcessor(name string) (resErr error) IsUpdateProcessorRunning(name string) (bool, error) //logger GetLogger() nxlog.Logger //requester GetRequesterURL() string SetRequesterPostURI(path string, queryPair map[string]string) error GetRequesterPostURI() string GetRequesterPostQuery() string RequesterPost() (string, error) //user management GetUser(userID int) (entity.User, bool) DisconnectUser(userID int) RemoveUser(userID int) GetUsers() []entity.User GetUserConnIDs() []string //manager GetHallManager() HallManager GetRoomManager() RoomManager //for grpc server //fn is grpc protobuf serivce register function. //example pb.RegisterGreeterServer(s, &server{}), s==*grpc.Server, &server{}=serverStruct{} contain rpc methods. //StartGRPCServer(addr, port string, registerServerFn interface{}, serverStruct interface{}) StartGRPCServer(registerServerFn interface{}, serverStruct interface{}) error GetGRPCClient(addr, port string, newClientFunc interface{}) (interface{}, error) GetGRPClientConn(address, port string) (*grpc.ClientConn, error) //http server StartHTTPServer(parameters *nxhttp.ServerParameters) error StopHTTPServer() GetHTTPServerRequestRealAddr(r *http.Request) (string, error) RegisterHTTPServerHandler(pattern string, handler http.Handler) }
Nex is used for main process
type PacketHandler ¶
type PacketHandler interface {
Handle(packetData *websocket.ReceivePacketData) ([]byte, string, error)
}
func NewPacketHandler ¶
func NewPacketHandler() (PacketHandler, error)
type RoomManager ¶
type RoomManager interface { CreateRoom(roomID int, typ int, name string) (entity.Room, error) RemoveRoom(roomID int) GetRoom(roomID int) (entity.Room, bool) GetRooms() []entity.Room }
func NewRoomManager ¶
func NewRoomManager() (RoomManager, error)
type UpdateManager ¶
type UpdateManager interface { RegisterProcessor(name string, p UpdateProcessor) error UnRegisterProcessor(name string) error StartProcessor(name string) (resErr error) StopProcessor(name string) (resErr error) IsRunning(name string) (bool, error) }
func NewUpdateManager ¶
func NewUpdateManager() (UpdateManager, error)
type UpdateObject ¶
type UpdateProcessor ¶
type UserManager ¶
type UserManager interface { CreateUser(connID string) (entity.User, error) RemoveUser(userID int) GetUser(userID int) (entity.User, bool) GetUserByConnID(connID string) (entity.User, bool) GetUsers() []entity.User }
func NewUserManager ¶
func NewUserManager() (UserManager, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.