servermanager

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 15 Imported by: 18

Documentation

Index

Constants

View Source
const (
	USER_LOGIN_SUCCESS = 0
	USER_ALREADY_LOGIN = 1
	USER_NOT_FOUND     = 2
	USER_PASSWD_ERROR  = 3
	USER_UNKOWN_ERROR  = 4
)

Variables

View Source
var (
	BFusername *BloomFilter
	BFgamename *BloomFilter
	DB         *sql.DB
	Dblock     sync.Mutex
	DBPath     string
	Redis      redis.Conn
)
View Source
var (
	LoginCounter     = map[string]int{}
	LoginCounterLock sync.Mutex
)
View Source
var (
	//MainServer 主服务器
	MainServer = ServerManager{
		0,
		[]*ChannelServer{},
	}
)
View Source
var (
	RoomsManager = RM{
		map[uint16]*Room{},
		&rmlock,
	}
)

Functions

func AddChannel

func AddChannel(dest *ChannelServer, src *ChannelInfo) bool

频道服务器里加频道,一次只能一个协程访问

func AddChannelRoom

func AddChannelRoom(room *Room, chlid uint8, chlsrvid uint8) bool

添加房间,一次只能一个协程修改该频道

func AddChannelServer

func AddChannelServer(dest *ServerManager, src *ChannelServer) bool

主服务器里加频道服务器,一次只能一个协程访问

func AddRoomToManager

func AddRoomToManager(room *Room) bool

添加房间,一次只能一个协程修改该频道

func AddUserToDB

func AddUserToDB(u *User) error

func BuildChannelList

func BuildChannelList(num uint8, channels []*ChannelInfo) []byte

func BuildChannelServerList

func BuildChannelServerList(chlsrv ChannelServer) []byte

建立某个频道服务器数据包

func ClearCount added in v0.3.9

func ClearCount(client string)

func CountFailLogin added in v0.3.9

func CountFailLogin(client string)

func CountTenMinutes added in v0.3.9

func CountTenMinutes(client string)

func DelChannelRoom

func DelChannelRoom(roomid uint16, chlid uint8, chlsrvid uint8) bool

删除频道房间

func DelChannelRoomQuick added in v0.3.15

func DelChannelRoomQuick(roomid uint16, chl *ChannelInfo) bool

快速删除频道房间,需预先取得锁

func DelRoomFromManager

func DelRoomFromManager(roomid uint16) bool

删除频道房间

func DelUserWithConn

func DelUserWithConn(con net.Conn) bool

func GetChannelServerWithID

func GetChannelServerWithID(id uint8) *ChannelServer

通过ID得到对应频道服务器

func GetChannelWithID

func GetChannelWithID(id uint8, chlsrv *ChannelServer) *ChannelInfo

通过ID获取频道

func GetNewChannelID

func GetNewChannelID(chlsrv ChannelServer) uint8

getNewChannelID() 暂定

func GetNewChannelServerID

func GetNewChannelServerID() uint8

新的频道服务器ID,一次只能一个协程访问

func GetNewRoomID

func GetNewRoomID(chl ChannelInfo) uint16

getNewRoomNumber() 获取房间在某个频道下的标号

func GetNewRoomNumber

func GetNewRoomNumber(chl ChannelInfo) uint8

getNewRoomNumber() 获取房间在某个频道下的标号

func GetNewUserID

func GetNewUserID() uint32

func GetRoomFromID

func GetRoomFromID(chlsrvID uint8, chlID uint8, roomID uint16) *Room

func GetUserByLogin

func GetUserByLogin(account string, passwd []byte) (*User, int)

getUserByLogin 假定nexonUsername是唯一

func GetUserFromConnection

func GetUserFromConnection(client net.Conn) *User

通过连接获取用户

func GetUserFromDatabase

func GetUserFromDatabase(loginname string, passwd []byte) (*User, int)

从数据库中读取用户数据 如果是新用户则保存到数据库中

func GetUserFromID

func GetUserFromID(id uint32) *User

通过ID获取用户

func GetUserFromIngameName added in v0.3.8

func GetUserFromIngameName(name []byte) *User

通过name获取用户

func InitBloomFilter added in v0.5.0

func InitBloomFilter() bool

func IsExistsIngameName added in v0.3.11

func IsExistsIngameName(name []byte) bool

func IsExistsUser

func IsExistsUser(username []byte) bool

func IsLoginTenth added in v0.3.9

func IsLoginTenth(client string) bool

func NewChannelInfo

func NewChannelInfo(name []byte, chlsrv ChannelServer) ChannelInfo

func NewChannelServer

func NewChannelServer(name []byte) ChannelServer

新建频道服务器

func NewMainServer

func NewMainServer() ServerManager

初始化主服务器,仅运行一次,不考虑互斥问题

func OnServerList

func OnServerList(client net.Conn)

处理请求服务器列表

func PathExists added in v0.3.11

func PathExists(path string) (bool, error)

func SaveAllUsers added in v0.3.15

func SaveAllUsers() bool

func UpdateUserToDB

func UpdateUserToDB(u *User) error

Types

type RM

type RM struct {
	Rooms map[uint16]*Room
	Lock  *sync.Mutex
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL