server

package
v1.0.1-0...-968bb1a Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddServerSpecs

func AddServerSpecs(db *gorm.DB, gameSession *GameSession) error

AddServerSpecs Add server specs

func AuthLogin

func AuthLogin(db *gorm.DB, user *Users) (string, error)

func CheckIfBarrierAddressExists

func CheckIfBarrierAddressExists(db *gorm.DB, barrierIP string) (bool, error)

CheckIfBarrierAddressExists Check if the barrier ip address with port exists

func CheckIfEmailAndPasswordMatch

func CheckIfEmailAndPasswordMatch(db *gorm.DB, emailID string, Password string) (string, error)

CheckIfEmailAndPasswordMatch Check email and password information for login

func CheckIfEmailExits

func CheckIfEmailExits(db *gorm.DB, Email string) error

CheckIfEmailExits Function to check if the username has been taken already or not

func CheckIfGameSessionIsActiveOrRemove

func CheckIfGameSessionIsActiveOrRemove(gorm *gorm.DB)

func Connect

func Connect() (*gorm.DB, error)

Connect Connection to the Sqlite database

func CreateTables

func CreateTables(db *gorm.DB) (*gorm.DB, error)

CreateTables CreateDB Add tables to the database

func GetUserID

func GetUserID(db *gorm.DB, emailID string) (string, error)

GetUserID Gets userID based on the EmailID

func MailerSend

func MailerSend(subject, email, message string) error

MailerSend This function sends an automated email to the person requesting it

func RegisterUser

func RegisterUser(db *gorm.DB, UserInformation *Users) error

RegisterUser Function to insert new user information

func RemoveBarrierIP

func RemoveBarrierIP(db *gorm.DB, barrierIP string) error

RemoveBarrierIP Remove barrier row based on the IP address provided

func RemoveLoginSession

func RemoveLoginSession(db *gorm.DB, SessionID string) error

RemoveLoginSession Removes session from the database based on the session ID provided

func RemoveTableGameSession

func RemoveTableGameSession(db *gorm.DB) (*gorm.DB, error)

RemoveTableGameSession Removes table of type

func RemoveTableGameSessionID

func RemoveTableGameSessionID(db *gorm.DB, id string) (*gorm.DB, error)

func Server

func Server(port string) error

Server Starts the server for the client side

Types

type BarrierIP

type BarrierIP struct {
	ID          string `bson: ID`
	BarrierIP   string `form:"BarrierIP" binding:"required" bson:hostname`
	MachineName string `form:"MachineName" binding:"required" bson:hostname`
	UserID      string `json:"UserID"`
	User        Users  `gorm:"foreignKey:UserID;references:UserID" json:"ServerInformation"`
}

BarrierIP Barrier connection information

func AddBarrierIP

func AddBarrierIP(db *gorm.DB, SessionID string, barrierIP string, MachineName string) (*BarrierIP, error)

AddBarrierIP Adds barrierIP information to barrier table

func GetBarrierInfo

func GetBarrierInfo(db *gorm.DB, SessionID string) (barriers []*BarrierIP, err error)

type GameSession

type GameSession struct {
	GameSessionID string `json:"GameSessionID"`
	// Link of the stream started for gameplay
	Link     string      `form:"Link" binding:"required" json:"LinkID"`
	ServerID string      `json:"ServerID"`
	Rate     float64     `form:"Rate"  binding:"required" json:"Rate"`
	Server   ServerSpecs `gorm:"foreignKey:ID;references:ServerID" json:"ServerInformation"`
	// State of the server if it's in use
	// or free
	State  bool
	UserID string `json:"UserID"`
	User   Users  `gorm:"foreignKey:UserID;references:UserID" json:"ServerInformation"`
}

GameSession A single Game session. In the following implementation the server can have only 1 user occupying it por session.

func DisplayGameSessions

func DisplayGameSessions(db *gorm.DB) ([]*GameSession, error)

DisplayGameSessions Returns all the rows of all the game session information to display

type LoginSession

type LoginSession struct {
	SessionKey string `json:"SessionKey"`
	UserID     string `json:"UserID"`
	User       Users  `gorm:"foreignKey:UserID;references:UserID" json:"Users"`
}

LoginSession Storing information of the login session

func CreateLoginSession

func CreateLoginSession(db *gorm.DB, user *Users) (*LoginSession, error)

CreateLoginSession function to create login session and setting expiry time for the login session

type ServerSpecs

type ServerSpecs struct {
	ID       string `bson: ID`
	Hostname string `form:"Hostname" binding:"required" bson:hostname`
	Platform string `form:"Platform" binding:"required" bson:platform`
	CPU      string `form:"CPU" binding:"required" bson:cpu`
	RAM      string `form:"RAM" binding:"required" bson:ram`
	Disk     string `form:"Disk" binding:"required" bson:disk`
	GPU      string `form:"GPU" binding:"required" bson:GPU`
}

ServerSpecs Server specs information

func GetSeverSpecs

func GetSeverSpecs(db *gorm.DB, ID string) (*ServerSpecs, error)

GetSeverSpecs Get server specs information based on the ID provided

type Users

type Users struct {
	UserID   string `json:"userID"`
	Name     string `form:"Name" json:"Name"`
	Password string `form:"Password" binding:"required" json:"Password"`
	EmailID  string `form:"EmailID" binding:"required" json:"EmailID"`
}

Users This struct focuses on storing user information

func GetUserInformation

func GetUserInformation(db *gorm.DB, SessionID string) (*Users, error)

GetUserInformation Gets the user information based on the session ID provided

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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