Versions in this module Expand all Collapse all v0 v0.0.4 Oct 24, 2021 Changes in this version + const AuthenticationLevelAppManager + const AuthenticationLevelDeveloper + const AuthenticationLevelProvider + const AuthenticationLevelUser + const ErrorCodeBadRequest + const ErrorCodeConnectionClosed + const ErrorCodeForbidden + const ErrorCodeInternal + const ErrorCodeNotFound + const ErrorCodeRoomAutoMatchError + const ErrorCodeRoomCreateError + const ErrorCodeRoomEnterError + const ErrorCodeRoomExitError + const ErrorCodeRoomLockError + const ErrorCodeRoomUnlockError + const ErrorCodeServerStopped + const ErrorCodeTooManyConnections + const ErrorCodeTooManyRequests + const ErrorCodeUnauthorized + const EventCodeErrorClient + const EventCodeErrorServer + const EventCodeRoomBroadcast + const EventCodeRoomCreated + const EventCodeRoomLocked + const EventCodeRoomRemoved + const EventCodeRoomUnlocked + const EventCodeRoomUpdated + const EventCodeRoomUserList + const EventCodeUserEnteredAOIMap + const EventCodeUserEnteredRoom + const EventCodeUserEnteredServer + const EventCodeUserExitedAOIMap + const EventCodeUserExitedRoom + const EventCodeUserExitedServer + const EventCodeUserMessage + const EventCodeUserMovedOnAOIMap + const EventCodeUserUpdated + const EventCodeUserValue + const HeaderV0Original + const PermissionCodeAdminAccess + const PermissionCodeAuthorized + const PermissionCodeCustomerSupportTicketAccess + const PermissionCodeIgnoreEventLimit + const PermissionCodeIgnoreMaintenance + const PermissionCodeNormalAccess + const PermissionCodeNotificationAccess + const PermissionCodeReadonlyAccess + const PermissionCodeSystemMailAccess + const PermissionCodeUserManagementAccess + const RequestCodeRoomAutoMatch + const RequestCodeRoomBroadcast + const RequestCodeRoomCreate + const RequestCodeRoomEnter + const RequestCodeRoomExit + const RequestCodeRoomLock + const RequestCodeRoomUnlock + const RequestCodeUserMessage + const RequestCodeUserValue + const RolePermissionAuthorized + const RolePermissionNormalUser + const RolePermissionOperator + const RolePermissionOperatorManager + const RolePermissionProprietor + const RolePermissionStaff + const RolePermissionUnauthorized + func NewServer(engine engine.Interface, listener Listener, c ServerConfig) (newServer *serverImpl, err error) + func RegisterHandler(id string, h Handler) + func RegisterMiddleware(id string, m Middleware) + func RegisterOnConnected(id string, h func(conn Connection)) + func RegisterOnDisconnected(id string, h func(conn Connection, errorCode ErrorCode)) + func RunHandler(ctx Ctx, builtinHandler string) + type AreaOfInterestMap struct + func NewAreaOfInterestMap(server Server, mapID uint16, sizeX float64, sizeY float64, cellNumW uint16, ...) (newMap *AreaOfInterestMap) + func (m *AreaOfInterestMap) Insert(connID uint16, userID []byte, x float64, y float64) + func (m *AreaOfInterestMap) Move(connID uint16, userID []byte, posX float64, posY float64, speed float64) + func (m *AreaOfInterestMap) OnInsertUser(fn func(connID uint16, userID []byte, x float64, y float64) (resp Response)) (ret *AreaOfInterestMap) + func (m *AreaOfInterestMap) OnMoveUser(...) (ret *AreaOfInterestMap) + func (m *AreaOfInterestMap) OnRemoveUser(fn func(connID uint16, userID []byte) (resp Response)) (ret *AreaOfInterestMap) + func (m *AreaOfInterestMap) Remove(connID uint16, userID []byte) + type Connection interface + AppID func() []byte + Close func(code ErrorCode, err string) + Server func() (server Server) + StringUserID func() string + Token func() []byte + UserID func() []byte + type Ctx interface + AppID func() []byte + Assert func(ok bool, format string, args ...interface{}) Ctx + Authorization func() interface{} + BroadcastApplication func(out ...Response) Ctx + BroadcastRoom func(out ...Response) Ctx + BroadcastServer func(out ...Response) Ctx + Cache func(cacheID ...string) (plugin *plugins.Cache) + CloseConnection func(code ErrorCode, err string) + ConnectionID func() uint16 + CsvTable func(tableName string, args ...string) plugins.MasterTable + CurrentRoomID func() uint16 + Debug func(format string, args ...interface{}) Ctx + ErrorClientRequest func(errorCode uint16, format string, args ...interface{}) + ErrorServerInternal func(format string, args ...interface{}) + EventCode func() uint16 + GetConnection func(ConnectionID uint16) Connection + Header func() uint8 + Infof func(format string, args ...interface{}) Ctx + IsInRoom func() bool + Now func() time.Time + OutMessage func() Response + Payload func() []byte + Redis func(instanceID ...string) (plugin *plugins.Redis) + Send func(destConnID uint16, out ...Response) Ctx + Server func() Server + SetAuthorization func(authorization interface{}) Ctx + Token func() []byte + UserID func() []byte + ValueTable func() CtxValueTable + Warnf func(format string, args ...interface{}) Ctx + type CtxValueTable interface + GetBool func(key int, def ...bool) bool + GetByte func(key int, def ...byte) byte + GetBytes func(key int) []byte + GetFloat32 func(key int, def ...float32) float32 + GetFloat64 func(key int, def ...float64) float64 + GetInt func(key int, def ...int) int + GetInt16 func(key int, def ...int16) int16 + GetString func(key int, def ...string) string + GetUint func(key int, def ...uint) uint + GetUint16 func(key int, def ...uint16) uint16 + Set func(key int, value interface{}) CtxValueTable + type ErrorCode = uint16 + type EventCode = uint16 + type Handler func(ctx Ctx) + func (h Handler) Combine(next ...Handler) Handler + type KcpConfig struct + Interval time.Duration + Mtu int + Nc bool + NoDelay bool + RcvWnd int + Resend int + SndWnd int + TurboLevel int + type KcpListener struct + Config *ServerConfig + func (l *KcpListener) Accept(context.Context) (connectionInterface, error) + type Listener interface + Accept func(context.Context) (connectionInterface, error) + Addr func() net.Addr + Close func() error + type Middleware func(h Handler) Handler + func (m Middleware) Apply(h Handler) Handler + func (m Middleware) Left(inner Middleware) Middleware + func (m Middleware) Right(outer Middleware) Middleware + type PermissionCode = int32 + type QuicConfig struct + type QuicListener struct + func (l *QuicListener) Accept(ctx context.Context) (connectionInterface, error) + type Request interface + Payload func() []byte + ReadBool func(val *bool) Request + ReadBytes func() []byte + ReadFloat32 func(val *float32) Request + ReadFloat64 func(val *float64) Request + ReadInt16 func(val *int16) Request + ReadInt32 func(val *int32) Request + ReadInt64 func(val *int64) Request + ReadInt8 func(val *int8) Request + ReadString func() string + ReadUint16 func(val *uint16) Request + ReadUint32 func(val *uint32) Request + ReadUint64 func(val *uint64) Request + ReadUint8 func(val *uint8) Request + type RequestCode = uint16 + type Response interface + Reset func() Response + SetEventCode func(code uint16) Response + SetHeader func(header uint8) Response + SetHeader2 func(protocolVer, cmd uint8) Response + WriteBool func(val bool) Response + WriteBytes func(val []byte) Response + WriteBytesNoLen func(val []byte) Response + WriteFloat32 func(val float32) Response + WriteFloat64 func(val float64) Response + WriteInt16 func(val int16) Response + WriteInt32 func(val int32) Response + WriteInt64 func(val int64) Response + WriteInt8 func(val int8) Response + WriteRoom func(roomID uint16) Response + WriteString func(val string) Response + WriteUint16 func(val uint16) Response + WriteUint32 func(val uint32) Response + WriteUint64 func(val uint64) Response + WriteUint8 func(val uint8) Response + WriteUserStatus func(connectionID uint16) Response + type RoomStatus struct + CreatedAt time.Time + ID uint16 + Mux []byte + RoomType uint8 + ScoreCenter float32 + ScoreVariance float32 + Status uint8 + UntilAt time.Time + UserNum uint16 + type Server interface + BroadcastMessageApplication func(appID []byte, out Response) + BroadcastMessageRoom func(roomID uint16, out Response) + BroadcastMessageServer func(out Response) + Cache func(cacheID string) (plugin *plugins.Cache) + ConnectionNum func() int + CreateRoom func() (roomID uint16, ok bool) + DestroyRoom func(roomID uint16) + Now func() time.Time + Redis func(instanceID string) (plugin *plugins.Redis) + RoomEnterUser func(roomID uint16, connectionID uint16) (ok bool) + RoomExitUser func(roomID uint16, connectionID uint16) (ok bool) + RoomSetMatch func(roomID uint16, mux []byte, scoreCenter float32, scoreVariance float32) + RoomSetUserNum func(roomID uint16, num uint16) + RoomStatus func(roomID uint16) *RoomStatus + RoomUserList func(roomID uint16) (list [][]byte) + RoomUserNum func(roomID uint16) int + SendMessage func(connID uint16, out Response) + SendMessageMultiple func(connectionIDList []uint16, out Response) + type ServerConfig struct + Address string + ByteOrder string + CertFile string + ControllerFilepath string + Heartbeat time.Duration + ID string + KeyFile string + Network string + Password string + Protocol string + ReadTimeout time.Duration + Salt string + WriteTimeout time.Duration