Added more logging to server

This commit is contained in:
qowevisa 2024-06-08 21:45:36 +03:00
parent c5e7f6c545
commit 99dbc74775
3 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"log"
"sync"
com "git.qowevisa.me/Qowevisa/gotell/communication"
@ -34,6 +35,7 @@ func (l *LinkCenter) AddLink(id uint16, link com.Link) error {
LeftNum: link.UseCount,
UserID: id,
}
log.Printf("Added link by %s\n", string(link.Data))
l.Mu.Unlock()
return nil
}
@ -46,6 +48,7 @@ func (l *LinkCenter) DeleteLink(data []byte) error {
}
func (l *LinkCenter) GetLink(data []byte) (*UserLink, error) {
log.Printf("LinkCenter : GetLink by : %s\n", string(data))
val, found := l.Links[string(data)]
if !found {
return nil, ERROR_DONT_HAVE

View File

@ -94,7 +94,7 @@ func handleClient(conn net.Conn) {
if err != nil {
answ, err := com.ServerSendClientDecline()
if err != nil {
log.Printf("ERROR: %v\n", err)
log.Printf("ERROR: BYTES: %v\n", err)
continue
}
conn.Write(answ)
@ -103,7 +103,7 @@ func handleClient(conn net.Conn) {
binary.BigEndian.PutUint16(idBytes, id)
answ, err := com.ServerSendClientHisID(idBytes)
if err != nil {
log.Printf("ERROR: %v\n", err)
log.Printf("ERROR: BYTES: %v\n", err)
continue
}
conn.Write(answ)
@ -136,7 +136,7 @@ func handleClient(conn net.Conn) {
case com.ID_CLIENT_ASK_SERVER_LINK:
link, err := linkCenter.GetLink(msg.Data)
if err != nil {
log.Printf("Error: %v\n", err)
log.Printf("Error: GetLink: %v\n", err)
continue
}
if link.LeftNum == 0 {

View File

@ -23,8 +23,8 @@ func (u *UserCenter) Init() {
}
var (
ERROR_ALREADY_HAVE = errors.New("Username is already taken")
ERROR_DONT_HAVE = errors.New("Username was not found")
ERROR_ALREADY_HAVE = errors.New("Already taken")
ERROR_DONT_HAVE = errors.New("Not found")
)
func (u *UserCenter) AddUser(name string) (uint16, error) {