This commit is contained in:
aozhiwei 2023-08-12 20:32:44 +08:00
parent 1e0148bd50
commit ec16fc1705
6 changed files with 25 additions and 31 deletions

3
app.go
View File

@ -175,9 +175,6 @@ func (this *App_) NowUnixNano() int64 {
} }
func (this *App_) outputRuningLog() { func (this *App_) outputRuningLog() {
for _, val := range q5.GetInitLogs() {
SysLog().Info("%s", val)
}
} }
func (this *App_) dispatchIMMsg() { func (this *App_) dispatchIMMsg() {

View File

@ -49,13 +49,17 @@ func (this *Context) GetRemoteAddr() string {
return q5.GetRequestRemoteAddr(this.r) return q5.GetRequestRemoteAddr(this.r)
} }
/*
func (this *Context) Request(name string) *q5.XValue { func (this *Context) Request(name string) *q5.XValue {
return q5.Request(this.r, name) return q5.Request(this.r, name)
} }
*/
/*
func (this *Context) GetBody() *q5.XValue { func (this *Context) GetBody() *q5.XValue {
return q5.GetPostBody(this.r) return q5.GetPostBody(this.r)
} }
*/
func (this *Context) Header(name string) string { func (this *Context) Header(name string) string {
if val, ok := this.r.Header[name]; ok { if val, ok := this.r.Header[name]; ok {
@ -70,10 +74,10 @@ func (this *Context) Response(data string) {
} }
func (this *Context)ResponseErr(errCode int32, errMsg string) { func (this *Context)ResponseErr(errCode int32, errMsg string) {
respObj := q5.NewMxoObject() /*respObj := q5.NewMxoObject()
respObj.SetXValue("errcode", q5.NewXInt32(errCode)) respObj.SetXValue("errcode", q5.NewXInt32(errCode))
respObj.SetXValue("errmsg", q5.NewXString(errMsg)) respObj.SetXValue("errmsg", q5.NewXString(errMsg))
q5.Response(this.w, respObj.ToJsonStr()) q5.Response(this.w, respObj.ToJsonStr())*/
} }
func (this *Context) ResponseOk() { func (this *Context) ResponseOk() {

View File

@ -75,6 +75,7 @@ func (this *HttpServer) Start(listen_port int32) {
} }
func (this *HttpServer) dispatchRequest(c *Context) { func (this *HttpServer) dispatchRequest(c *Context) {
/*
atomic.AddInt64(&this.totalRequestTimes, 1) atomic.AddInt64(&this.totalRequestTimes, 1)
handleName := c.Request("c").GetString() + "$" + c.Request("a").GetString() handleName := c.Request("c").GetString() + "$" + c.Request("a").GetString()
handle := this.getHandle(handleName) handle := this.getHandle(handleName)
@ -95,7 +96,7 @@ func (this *HttpServer) dispatchRequest(c *Context) {
} else { } else {
c.Response(`{"errcode":404, "errmsg":"interface not found"}`) c.Response(`{"errcode":404, "errmsg":"interface not found"}`)
atomic.AddInt64(&this.pageNotFoundTimes, 1) atomic.AddInt64(&this.pageNotFoundTimes, 1)
} }*/
} }
func (this *HttpServer) getHandle(handleName string) HandlerFunc { func (this *HttpServer) getHandle(handleName string) HandlerFunc {

View File

@ -97,9 +97,9 @@ func (this *SysLog_) addLog(category string, format string, args ...interface{})
p.logMsg = time.Now().Format("2006-01-02 15:04:05") + p.logMsg = time.Now().Format("2006-01-02 15:04:05") +
category + " " + category + " " +
fmt.Sprintf(format, args...) + "\n" fmt.Sprintf(format, args...) + "\n"
if q5.Debug() { /*if q5.Debug() {
fmt.Print(p.logMsg) fmt.Print(p.logMsg)
} }*/
this.msgMutex.Lock() this.msgMutex.Lock()
defer this.msgMutex.Unlock() defer this.msgMutex.Unlock()
if this.botNode != nil { if this.botNode != nil {

View File

@ -2,8 +2,8 @@ package f5
import ( import (
"os" "os"
"strings" //"strings"
"q5" //"q5"
) )
const ( const (
@ -26,19 +26,7 @@ func IsDevEnv() bool {
return serverEnv == DEV_ENV return serverEnv == DEV_ENV
} }
func IsValidSessionId(accountId string, sessionId string, key string) bool { /*
tmpStrings := strings.Split(sessionId, "_")
if len(tmpStrings) < 4 {
return false
}
sessionCreateTime := new(q5.XValue).SetString(tmpStrings[0]).GetString()
registerTime := new(q5.XValue).SetString(tmpStrings[1]).GetString()
md5Str := new(q5.XValue).SetString(tmpStrings[2]).GetString()
//SysLog().Debug("%s", accountId + key + registerTime + sessionCreateTime)
//SysLog().Debug("md51=%s md52=%s", q5.Md5Str(accountId + key + registerTime + sessionCreateTime), md5Str)
return q5.Md5Str(accountId + key + registerTime + sessionCreateTime) == md5Str
}
func ExtractRegisterTimeFromSessionId(sessionId string) int64 { func ExtractRegisterTimeFromSessionId(sessionId string) int64 {
tmpStrings := strings.Split(sessionId, "_") tmpStrings := strings.Split(sessionId, "_")
if len(tmpStrings) < 4 { if len(tmpStrings) < 4 {
@ -70,7 +58,7 @@ func ExtractOpenIdFromAccountId(accountId string) string {
} }
return strings.Join(tmpStrings[2:], "_") return strings.Join(tmpStrings[2:], "_")
} }
*/
func New[T any](cb func(*T)) *T { func New[T any](cb func(*T)) *T {
obj := new(T) obj := new(T)
cb(obj) cb(obj)

View File

@ -1,10 +1,10 @@
package f5 package f5
import "os" //import "os"
import "fmt" //import "fmt"
import "sync" import "sync"
import "time" //import "time"
import "q5" //import "q5"
const TGLOG_ROOT = "/data/logs/%s/upload/" const TGLOG_ROOT = "/data/logs/%s/upload/"
const POLY_TGLOG_ROOT = "/data/logs/%s/%d/upload/" const POLY_TGLOG_ROOT = "/data/logs/%s/%d/upload/"
@ -26,7 +26,7 @@ type TGLog_ struct {
func (this *TGLog_) Init() { func (this *TGLog_) Init() {
this.chGoSaveExit = make(chan int) this.chGoSaveExit = make(chan int)
go this.goSaveToFile() //go this.goSaveToFile()
} }
func (this *TGLog_) UnInit() { func (this *TGLog_) UnInit() {
@ -37,6 +37,7 @@ func (this *TGLog_) SetPolyLog(isPolyLog bool) {
this.isPolyLog = isPolyLog this.isPolyLog = isPolyLog
} }
/*
func (this *TGLog_) AddTrackLog( func (this *TGLog_) AddTrackLog(
gameId int32, gameId int32,
accountId string, accountId string,
@ -75,8 +76,9 @@ func (this *TGLog_) AddTrackLogEx(
this.topNode = p this.topNode = p
this.botNode = p this.botNode = p
} }
} //}
*/
/*
func (this *TGLog_) goSaveToFile() { func (this *TGLog_) goSaveToFile() {
var workNode *TGLogMsgNode var workNode *TGLogMsgNode
for { for {
@ -119,3 +121,5 @@ func (this *TGLog_) getLogFile(gameId int32) *os.File {
return nil return nil
} }
} }
*/