Documentation
¶
Index ¶
- Constants
- Variables
- func AppendLogToFile(data *Log, filePath string) error
- func ComparePasswords(hashedPassword string, enteredPassword string) error
- func CreateWebClipboardFile() error
- func DownloadAllObjKeys(bucketName string, prefix string, region string) ([]string, error)
- func DownloadAndWriteNoteData() error
- func DownloadFile(bucketName string, objPath string, region string) ([]byte, error)
- func FileExists(filePath string) bool
- func GetClientsStr(c *ClientsMap[Client]) string
- func GetObjectKeys() (*[]FileInfo, error)
- func HashPassword(password string) (string, error)
- func InitDirs()
- func InitFiles()
- func InitGlobalVars()
- func InitSetupFunc()
- func LogData(data ...string)
- func LogDataToPath(logFilePath string, data ...string)
- func S3_DownloadFiles() error
- func S3_ObjectInfoArr()
- type Client
- type ClientsMap
- type Code_Generator
- type ErrorMessage
- type FTPayload
- type FT_MetaData_plusCONN
- type FT_Transfer
- type FileInfo
- type Log
- type Message
- type MetaDataFmt
- type PlayerClient
- type S3_File
- type ServerError
- type SuccessMessage
- type UserProfile
- type UserRegister
Constants ¶
const ( C2A = "client-to-all" C2S = "client-to-server" S2C = "server-to-client" // Server to single client broadcast S2A = "server-to-all" // Global client broadcast )
const ( SERVER_ERR = 500 CLIENT_ERR = 400 )
const ( METADATA = "metadata" RECEIV_URL = "receiverURL" )
Variables ¶
var ( ChatClientsMap = NewClientsMap[Client]() Id_Gen *id_Generator = &id_Generator{ start_ID: 0, } ConnUpgrader = websocket.Upgrader{} )
var ( PORT string // files REQUEST_LOG_PATH string SERVER_LOG_PATH string CLIPBOARD_PATH_JSON string CLIPBOARD_PATH_TXT string DUMMY_WS_LOG_PATH string CHAT_DEBUG string CHAT_LOG string // --- CHAT_PASS string BUCKET_NAME string BUCKET_REGION string OBJ_RESUME_KEY string OBJ_RESUME_PNG_KEY string OBJ_RESUME_HTML_KEY string OBJ_RESUME_MD_KEY string NOTES_DATA_FOLDER string LOCAL_INFO_PATH string LOCAL_RESUME_PATH string LOCAL_RESUME_PNG_PATH string LOCAL_RESUME_HTML_PATH string LOCAL_RESUME_MD_PATH string QUERY_GENERAL_PASS string QUERY_TRIGGER_PASS string DB_URL string DB_API_KEY string )
var (
FT_Map = make(map[string]*FT_Transfer)
)
var (
S3_Files = []S3_File{}
)
Functions ¶
func AppendLogToFile ¶
Difference between this and LogData is that this logs to a given file, while the other has a default filepath. Actually nvm idk
func ComparePasswords ¶
func CreateWebClipboardFile ¶
func CreateWebClipboardFile() error
This file needs to be created beforehand unlike others because its json and has a structure.
func DownloadAllObjKeys ¶
func DownloadAndWriteNoteData ¶
func DownloadAndWriteNoteData() error
func DownloadFile ¶
Download the resource file from the given s3 bucket
func FileExists ¶
Check if a file exists at the given filepath.
func GetClientsStr ¶
func GetClientsStr(c *ClientsMap[Client]) string
Returns a string of all the online clients
func HashPassword ¶
func InitGlobalVars ¶
func InitGlobalVars()
func InitSetupFunc ¶
func InitSetupFunc()
func LogDataToPath ¶
Log text data to a give filepath. If the file doesnt exist, it is created. Variadic function that can take any number of data.
func S3_DownloadFiles ¶
func S3_DownloadFiles() error
Types ¶
type ClientsMap ¶
Hashmap of a client against their id.
var (
GamePlayersMap *ClientsMap[PlayerClient] = NewClientsMap[PlayerClient]()
)
func NewClientsMap ¶
func NewClientsMap[T any]() *ClientsMap[T]
func (*ClientsMap[T]) AddClient ¶
func (c *ClientsMap[T]) AddClient(clientID string, client *T)
func (*ClientsMap[T]) DeleteClient ¶
func (c *ClientsMap[T]) DeleteClient(clientID string)
func (*ClientsMap[T]) GetClient ¶
func (c *ClientsMap[T]) GetClient(clientID string) (*T, bool)
func (*ClientsMap[T]) UpdateClient ¶
func (c *ClientsMap[T]) UpdateClient(clientID string, updateFunc func(client *T) *T)
type Code_Generator ¶
type Code_Generator struct {
Start_ID uint8
}
generate unique code Limited to uint8 for now Easier to work encode in byte code idk
var (
Tunneling_code_generator Code_Generator = Code_Generator{
Start_ID: 1,
}
)
func (*Code_Generator) NewCode ¶
func (idGen *Code_Generator) NewCode() uint8
Just increments the default value
type ErrorMessage ¶
func ClientErr ¶
func ClientErr(messageStr ...string) ErrorMessage
func InternalServerErr ¶
func InternalServerErr(messageStr string) ErrorMessage
func (*ErrorMessage) Error ¶
func (e *ErrorMessage) Error() string
type FT_MetaData_plusCONN ¶
type FT_MetaData_plusCONN struct {
ReceiverUrl string
ConnID string
Filename string
FileByteSize int64
ReceiverConn *websocket.Conn
SenderConn *websocket.Conn
}
All of the metadata recerverURL, connID, filename, fileByteSize
type FT_Transfer ¶
type MetaDataFmt ¶
type PlayerClient ¶
type ServerError ¶
Custom Server Error
func (*ServerError) Error ¶
func (ce *ServerError) Error() string
type SuccessMessage ¶
type SuccessMessage struct {
Message string `json:"message"`
}
type UserProfile ¶
type UserProfile struct {
Id int `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Email string `json:"email"`
}
func GetUserFromEmail ¶
func GetUserFromEmail(email string) ([]UserProfile, error)
Returns user array given the email. If the provided email not in the db, returns an empty array. This allows to check whether the user exists or no. Remember to account for offline db server.
type UserRegister ¶
type UserRegister struct {
Username string `json:"username"`
Password string `json:"password"`
Email string `json:"email"`
}
The Id in UserProfile defaults to 0 which results in a conflict