core

package
v0.0.0-...-d1209a5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NebErrorNone = iota
	// Generic error
	NebError = iota
	// Session is dead, you were disconnected
	NebErrorDisconnected = iota
	// Login failed
	NebErrorLogin = iota
	// There were errors during multiple operations
	NebErrorPartialFail = iota
	// User is not authorized to do that
	NebErrorAuthFail = iota
)
View Source
const (
	UserMaskBase = 1 << iota
	UserMaskOnlyId
	UserMaskAchievements
	UserMaskStats
	UserMaskAll = UserMaskStats | UserMaskAchievements
)
View Source
const (
	UserRankBanned = 1 << iota
	UserRankNormal
	UserRankDev
	UserRankAdmin
	UserRankTester
)
View Source
const NebuleuseVersion = 1

Variables

View Source
var (
	Trace     *log.Logger
	Info      *log.Logger
	Warning   *log.Logger
	Error     *log.Logger
	LogWriter *io.Writer
)
View Source
var Cfg configMgr
View Source
var Db *sql.DB

Functions

func AddBranchFromBuild

func AddBranchFromBuild(build, accessRank int, name, log, semver string) error

func AddEmptyBranch

func AddEmptyBranch(name string, accessRank int) error

func AddStatTable

func AddStatTable(table ComplexStatTableInfo) error

func AddUserStatFields

func AddUserStatFields(name string) error

func CanUserAccessBranch

func CanUserAccessBranch(name string, rank int) bool

If branch doesn't exist, returns false

func CanUserDispatch

func CanUserDispatch(pipe string) bool

func CanUserJoin

func CanUserJoin(pipe string, user *UserSession) bool

func CountOnlineUsers

func CountOnlineUsers() int

func CreateBuild

func CreateBuild(log string) error

func CreateGitBuild

func CreateGitBuild(commit string, log string) error

func CreateSession

func CreateSession(username string, password string) (string, error)

func CreateUpdate

func CreateUpdate(build int, branch, semver, log string) error

func DeleteAchievementData

func DeleteAchievementData(id int) error

func DeleteStatTable

func DeleteStatTable(name string) error

func DeleteUserStatFields

func DeleteUserStatFields(name string) error

func Die

func Die()

func DisconnectUser

func DisconnectUser(userid int)

func Dispatch

func Dispatch(pipe, name string, message interface{})

func DispatchRank

func DispatchRank(pipe, name string, message interface{}, rank int)

func GenerateSessionId

func GenerateSessionId(username string) string

func GetBranchActiveBuild

func GetBranchActiveBuild(branchName string) (int, error)

func GetBranchList

func GetBranchList(rank int) []string

func GetBuildsCount

func GetBuildsCount() int

func GetCompleteUpdatesInfos

func GetCompleteUpdatesInfos() completeBranchUpdatesData

func GetLatestBuildCommit

func GetLatestBuildCommit() (string, error)

func GetMessages

func GetMessages(userid int) chan string

func GetPastLogs

func GetPastLogs(size int64) string

func GetProductionBranch

func GetProductionBranch() string

func GetUpdateSystem

func GetUpdateSystem() string

func GetUpdaterVersion

func GetUpdaterVersion() int

func GetUpdatesLocation

func GetUpdatesLocation() string

func GetUserCount

func GetUserCount() int

func GetUserStatsFields

func GetUserStatsFields() ([]string, error)

func HashPassword

func HashPassword(password string, hash string) string

func Init

func Init()

func Install

func Install()

func IsUserLongPolling

func IsUserLongPolling(userid int) bool

func Listen

func Listen(pipe, name string, user *UserSession)

func PrepareGitBuild

func PrepareGitBuild(commit string) (gitBuildPrepInfos, error)

func PurgeSessions

func PurgeSessions()

func RegisterUser

func RegisterUser(username string, password string, rank int) error

func SendMessageToUserId

func SendMessageToUserId(user *UserSession, message string)

func SetAchievementData

func SetAchievementData(id int, data AchievementData) error

func SetActiveUpdate

func SetActiveUpdate(branchName string, buildId int) error

func SetStatFields

func SetStatFields(table ComplexStatTableInfo) error

func SetStatTable

func SetStatTable(table ComplexStatTableInfo) error

func SetUsersStatFields

func SetUsersStatFields(fields string) error

func SignalGameUpdated

func SignalGameUpdated(branch Branch, update Update)

func StopListen

func StopListen(pipe, name string, user *UserSession)

func UpdateGitCommitCache

func UpdateGitCommitCache() error

func UserStopListen

func UserStopListen(user *UserSession)

Types

type Achievement

type Achievement struct {
	Id       int
	Name     string
	Progress uint
	Max      uint
	Icon     string
}

Achievements

type AchievementData

type AchievementData struct {
	Id       int
	Name     string
	Max      int
	FullName string
	FullDesc string
	Icon     string
}

func AddAchievementData

func AddAchievementData(data AchievementData) (AchievementData, error)

func GetAchievementData

func GetAchievementData(id string) (AchievementData, error)

func GetAchievementsData

func GetAchievementsData() ([]AchievementData, error)

type Branch

type Branch struct {
	Name        string
	AccessRank  int
	ActiveBuild int
	Head        *Update `json:"-"`
}

func GetBranch

func GetBranch(name string) (*Branch, error)

type Build

type Build struct {
	Id          int
	Commit      string
	Log         string
	Date        time.Time
	FileChanged string
	Obselete    bool
	Updates     map[string]*Update `json:"-"`
}

func GetBuild

func GetBuild(id int) (*Build, error)

type Commit

type Commit struct {
	Id        string
	Message   string
	Committer string
	Date      string

	TotalAddition, TotalDeletion int
	Diff                         []Diff
}

func GetGitCommitList

func GetGitCommitList() ([]Commit, error)

type ComplexStat

type ComplexStat struct {
	Name   string
	Values []KeyValue
}

type ComplexStatTableInfo

type ComplexStatTableInfo struct {
	Name      string
	Fields    []FieldStruct
	AutoCount bool
}

func GetComplexStatsTableInfos

func GetComplexStatsTableInfos(table string) (ComplexStatTableInfo, error)

func GetComplexStatsTablesInfos

func GetComplexStatsTablesInfos() ([]ComplexStatTableInfo, error)

type DashboardLogWriter

type DashboardLogWriter struct {
}

func (*DashboardLogWriter) Write

func (w *DashboardLogWriter) Write(p []byte) (n int, err error)

type Diff

type Diff struct {
	Name               string
	Index              int
	Addition, Deletion int
	Type               int
	IsCreated          bool
	IsDeleted          bool
	IsBin              bool
}

type FieldStruct

type FieldStruct struct {
	Name string
	Type string
	Size int
}

type KeyValue

type KeyValue struct {
	Name  string
	Value string
}

type MessagePipeline

type MessagePipeline struct {
	// contains filtered or unexported fields
}

type NebuleuseError

type NebuleuseError struct {
	Code int
	Msg  string
}

func (NebuleuseError) Error

func (e NebuleuseError) Error() string

type Update

type Update struct {
	Build        *Build `json:"-"`
	BuildId      int
	Branch       string
	Size         int64
	RollBack     bool
	SemVer       string
	Log          string
	Date         time.Time
	NextInBranch *Update `json:"-"`
	PrevInBranch *Update `json:"-"`
}

func GetBranchHead

func GetBranchHead(name string) (*Update, error)

func GetBranchUpdates

func GetBranchUpdates(name string) ([]Update, error)

Only return updates that are active or are older than the active one

func GetUpdateInfos

func GetUpdateInfos(branchName string, buildId int) (*Update, error)

type User

type User struct {
	Id           int
	Username     string
	Rank         int
	Avatar       string
	Achievements []Achievement
	Stats        []UserStat
}

User

func GetUserBySession

func GetUserBySession(SessionId string, BitMask int) (*User, error)

func GetUsersInfos

func GetUsersInfos(start, count, mask int) ([]*User, error)

func (*User) Disconnect

func (u *User) Disconnect()

func (*User) FetchUserInfos

func (u *User) FetchUserInfos(Bitmask int) error

func (*User) Heartbeat

func (u *User) Heartbeat()

func (*User) PopulateAchievements

func (u *User) PopulateAchievements() error

func (*User) PopulateStats

func (u *User) PopulateStats() error

We load complex stats informations stored in neb_stats_tables to make a list of stats the user has. Entry for users is the users' fields and entries with AutoCount true are additional fields updated when a complex stat is added

func (*User) SetAchievementProgress

func (u *User) SetAchievementProgress(aid int, value int) error

func (*User) SetComplexStats

func (u *User) SetComplexStats(stats []ComplexStat) error

func (*User) SetStats

func (u *User) SetStats(stats []UserStat) error

type UserSession

type UserSession struct {
	LongPolling bool `json:"-"`
	LastAlive   time.Time
	SessionId   string
	UserId      int
	UserRank    int
	Messages    chan string `json:"-"`
	TimedOut    chan int    `json:"-"`
}

func GetOnlineUsersList

func GetOnlineUsersList() []UserSession

func GetSessionBySessionId

func GetSessionBySessionId(sessionid string) *UserSession

func GetSessionByUserId

func GetSessionByUserId(userid int) *UserSession

func (*UserSession) Heartbeat

func (s *UserSession) Heartbeat()

type UserStat

type UserStat struct {
	Name  string
	Value int64
}

Jump to

Keyboard shortcuts

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