1
This commit is contained in:
parent
2a32689357
commit
dfb742786b
22
app.go
22
app.go
@ -4,6 +4,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"os"
|
||||||
"q5"
|
"q5"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,6 +59,10 @@ func (this *App_) Init() {
|
|||||||
this.chGoLoopTimerExit = make(chan int)
|
this.chGoLoopTimerExit = make(chan int)
|
||||||
this.chGoLoopWait = make(chan int64)
|
this.chGoLoopWait = make(chan int64)
|
||||||
this.outputRuningLog()
|
this.outputRuningLog()
|
||||||
|
SysLog().Info("node_id:%d instance_id:%d pid:%d",
|
||||||
|
this.nodeId,
|
||||||
|
this.instanceId,
|
||||||
|
os.Getpid())
|
||||||
go this.goLoopTimer()
|
go this.goLoopTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +76,7 @@ func (this *App_) Run() {
|
|||||||
for !this.terminated {
|
for !this.terminated {
|
||||||
this.nowTime = time.Now()
|
this.nowTime = time.Now()
|
||||||
_Timer.Update()
|
_Timer.Update()
|
||||||
|
this.dispatchIMMsg()
|
||||||
this.schedule()
|
this.schedule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,3 +161,19 @@ func (this *App_) outputRuningLog() {
|
|||||||
SysLog().Info("%s", val)
|
SysLog().Info("%s", val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *App_) dispatchIMMsg() {
|
||||||
|
this.imMsgMutex.Lock()
|
||||||
|
this.imWorkNode = this.imTopNode
|
||||||
|
this.imTopNode = nil
|
||||||
|
this.imBotNode = nil
|
||||||
|
this.imMsgMutex.Unlock()
|
||||||
|
|
||||||
|
for this.imWorkNode != nil {
|
||||||
|
currNode := this.imWorkNode
|
||||||
|
this.imWorkNode = this.imWorkNode.next
|
||||||
|
if this.imMsgHandlers[currNode.msgId] != nil {
|
||||||
|
this.imMsgHandlers[currNode.msgId](currNode.msgId, currNode.params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -34,7 +34,9 @@ func IsValidSessionId(accountId string, sessionId string, key string) bool {
|
|||||||
sessionCreateTime := new(q5.XValue).SetString(tmpStrings[0]).GetString()
|
sessionCreateTime := new(q5.XValue).SetString(tmpStrings[0]).GetString()
|
||||||
registerTime := new(q5.XValue).SetString(tmpStrings[1]).GetString()
|
registerTime := new(q5.XValue).SetString(tmpStrings[1]).GetString()
|
||||||
md5Str := new(q5.XValue).SetString(tmpStrings[2]).GetString()
|
md5Str := new(q5.XValue).SetString(tmpStrings[2]).GetString()
|
||||||
return q5.Md5Str(accountId + registerTime + sessionCreateTime) == md5Str
|
//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) int32 {
|
func ExtractRegisterTimeFromSessionId(sessionId string) int32 {
|
||||||
|
8
tglog.go
8
tglog.go
@ -7,7 +7,7 @@ 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/%s/upload/"
|
const POLY_TGLOG_ROOT = "/data/logs/%s/%d/upload/"
|
||||||
const TGLOG_FILENAME = "log_%d_%s.log"
|
const TGLOG_FILENAME = "log_%d_%s.log"
|
||||||
|
|
||||||
type TGLogMsgNode struct {
|
type TGLogMsgNode struct {
|
||||||
@ -54,7 +54,8 @@ func (this *TGLog_) AddTrackLogEx(
|
|||||||
remoteAddr string,
|
remoteAddr string,
|
||||||
eventName string,
|
eventName string,
|
||||||
prop *q5.XObject) {
|
prop *q5.XObject) {
|
||||||
var xobj *q5.MutableXObject
|
//SysLog().Info("TGLog.AddTrackLogEx")
|
||||||
|
xobj := q5.NewMxoObject()
|
||||||
xobj.SetXValue("#account_id", new(q5.XValue).SetString(accountId))
|
xobj.SetXValue("#account_id", new(q5.XValue).SetString(accountId))
|
||||||
xobj.SetXValue("#type", new(q5.XValue).SetString("track"))
|
xobj.SetXValue("#type", new(q5.XValue).SetString("track"))
|
||||||
xobj.SetXValue("#time", new(q5.XValue).SetString(time.Now().Format("2006-01-02 15:04:05")))
|
xobj.SetXValue("#time", new(q5.XValue).SetString(time.Now().Format("2006-01-02 15:04:05")))
|
||||||
@ -111,9 +112,10 @@ func (this *TGLog_) getLogFile(gameId int32) *os.File {
|
|||||||
logDir = fmt.Sprintf(TGLOG_ROOT, App.GetPkgName())
|
logDir = fmt.Sprintf(TGLOG_ROOT, App.GetPkgName())
|
||||||
}
|
}
|
||||||
q5.ForceCreateDir(logDir)
|
q5.ForceCreateDir(logDir)
|
||||||
if f, err := os.OpenFile(logDir + fileName, os.O_WRONLY|os.O_APPEND, 0666); err == nil {
|
if f, err := os.OpenFile(logDir + fileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666); err == nil {
|
||||||
return f
|
return f
|
||||||
} else {
|
} else {
|
||||||
|
SysLog().Warning("TGLog.goSaveToFile err:%s", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user