本文整理汇总了Golang中gk/gklog.LogTrace函数的典型用法代码示例。如果您正苦于以下问题:Golang LogTrace函数的具体用法?Golang LogTrace怎么用?Golang LogTrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogTrace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: sendSingleAvatarObject
func (fieldContext *FieldContextDef) sendSingleAvatarObject(websocketConnectionContext *websocketConnectionContextDef, fieldObject *fieldObjectDef) *gkerr.GkErrDef {
var gkErr *gkerr.GkErrDef
var svgJsonData *message.SvgJsonDataDef = new(message.SvgJsonDataDef)
svgJsonData.Id = fieldObject.id
svgJsonData.IsoXYZ = fieldObject.isoXYZ
gklog.LogTrace("sourceSessionId: " + fieldObject.sourceSessionId)
if fieldObject.sourceSessionId != websocketConnectionContext.sessionId {
var singleSession *ses.SingleSessionDef
singleSession = fieldContext.sessionContext.GetSessionFromId(fieldObject.sourceSessionId)
svgJsonData.UserName = singleSession.GetUserName()
gklog.LogTrace("going to send to ws userName: " + singleSession.GetUserName())
}
var messageToClient *message.MessageToClientDef = new(message.MessageToClientDef)
gkErr = messageToClient.BuildSvgMessageToClient(fieldContext.avatarSvgDir, message.AddSvgReq, fieldObject.fileName, svgJsonData)
if gkErr != nil {
return gkErr
}
fieldContext.queueMessageToClient(websocketConnectionContext.sessionId, messageToClient)
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:25,代码来源:fieldContext.go
示例2: getUserFromToken
func (tokenContext *tokenContextDef) getUserFromToken(token string) string {
var ok bool
var tokenEntry *tokenEntryDef
tokenContext.purgeOldTokenEntries()
tokenContext.tokenMutex.Lock()
defer tokenContext.tokenMutex.Unlock()
gklog.LogTrace(fmt.Sprintf("getting token entry: %+v", token))
tokenEntry, ok = tokenContext.tokenMap[token]
if !ok {
gklog.LogTrace("did not find")
return ""
}
var userName string
userName = tokenEntry.userName
gklog.LogTrace("found " + userName)
// token cannot be reused
// but for now we allow it to be reused :)
//delete(tokenContext.tokenMap,tokenEntry.tokenId)
return userName
}
开发者ID:gk-turnip,项目名称:server,代码行数:28,代码来源:tokenContext.go
示例3: moveAllAvatarBySessionId
// an avatar is moving from one pod to another
// so delete any object matching by sessionId from old pod
// then add them to the new pod
func (fieldContext *FieldContextDef) moveAllAvatarBySessionId(sessionId string, oldPodId int32, newPodId int32, destinationX int16, destinationY int16, destinationZ int16) *gkerr.GkErrDef {
gklog.LogTrace("moving all object by session id")
var gkErr *gkerr.GkErrDef
for _, fieldObject := range fieldContext.podMap[oldPodId].avatarMap {
if fieldObject.sourceSessionId == sessionId {
var messageToClient *message.MessageToClientDef = new(message.MessageToClientDef)
messageToClient.Command = message.DelSvgReq
messageToClient.JsonData = []byte(fmt.Sprintf("{ \"id\": \"%s\"}", fieldObject.id))
messageToClient.Data = make([]byte, 0, 0)
for _, websocketConnectionContext := range fieldContext.podMap[oldPodId].websocketConnectionMap {
if sessionId == websocketConnectionContext.sessionId {
fieldObject.isoXYZ.X = destinationX
fieldObject.isoXYZ.Y = destinationY
fieldObject.isoXYZ.Z = destinationZ
gklog.LogTrace(fmt.Sprintf("moveAllAvatarBySessionId new destination: %d,%d,%d", fieldObject.isoXYZ.X, fieldObject.isoXYZ.Y, fieldObject.isoXYZ.Z))
}
fieldContext.queueMessageToClient(websocketConnectionContext.sessionId, messageToClient)
}
for _, websocketConnectionContext := range fieldContext.podMap[newPodId].websocketConnectionMap {
gkErr = fieldContext.sendSingleAvatarObject(websocketConnectionContext, fieldObject)
if gkErr != nil {
return gkErr
}
}
delete(fieldContext.podMap[oldPodId].avatarMap, fieldObject.id)
fieldContext.podMap[newPodId].avatarMap[fieldObject.id] = fieldObject
}
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:38,代码来源:fieldContext.go
示例4: handleGameInitial
func (httpContext *httpContextDef) handleGameInitial(res http.ResponseWriter, req *http.Request) {
var gameData gameDataDef
var gkErr *gkerr.GkErrDef
var singleSession *ses.SingleSessionDef
var token string
token = req.Form.Get(_tokenParam)
gklog.LogTrace("got token: " + token)
var userName string
userName = httpContext.tokenContext.getUserFromToken(token)
gklog.LogTrace("got username: " + userName)
if len(userName) < 3 {
httpContext.redirectToError("not valid token", res, req)
return
}
var lastPodId int32
lastPodId, gkErr = httpContext.persistenceContext.GetLastPodId(userName)
if gkErr != nil {
errorMessage := "persistenceContext.getLastPodName"
gklog.LogGkErr(errorMessage, gkErr)
httpContext.redirectToError(errorMessage, res, req)
return
}
singleSession = httpContext.sessionContext.NewSingleSession(userName, lastPodId, req.RemoteAddr)
gameData.Title = "game"
gameData.WebAddressPrefix = httpContext.gameConfig.WebAddressPrefix
gameData.WebsocketAddressPrefix = httpContext.gameConfig.WebsocketAddressPrefix
gameData.AudioAddressPrefix = httpContext.gameConfig.AudioAddressPrefix
gameData.WebsocketPath = httpContext.gameConfig.WebsocketPath
gameData.SessionId = singleSession.GetSessionId()
gkErr = _gameTemplate.Build(gameData)
if gkErr != nil {
errorMessage := "_gameTemplate.Build"
gklog.LogGkErr(errorMessage, gkErr)
httpContext.redirectToError(errorMessage, res, req)
return
}
gkErr = _gameTemplate.Send(res, req)
if gkErr != nil {
gklog.LogGkErr("_gameTemplate.Send", gkErr)
return
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:49,代码来源:httpContext.go
示例5: ServeHTTP
func (tokenContext *tokenContextDef) ServeHTTP(res http.ResponseWriter, req *http.Request) {
path := req.URL.Path
gklog.LogTrace(req.Method)
gklog.LogTrace(path)
if req.Method == _methodGet || req.Method == _methodPost {
if gknet.RequestMatches(path, _tokenRequest) {
tokenContext.handleTokenRequest(res, req)
} else {
http.NotFound(res, req)
}
} else {
http.NotFound(res, req)
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:16,代码来源:tokenContext.go
示例6: queueMessageToClient
func (fieldContext *FieldContextDef) queueMessageToClient(sessionId string, messageToClient *message.MessageToClientDef) {
var websocketConnectionContext *websocketConnectionContextDef
var gkErr *gkerr.GkErrDef
gklog.LogTrace("queu up message " + messageToClient.Command)
websocketConnectionContext, gkErr =
fieldContext.getWebsocketConnectionContextById(sessionId)
if gkErr != nil {
gklog.LogGkErr("", gkErr)
} else {
var localSize int
websocketConnectionContext.toClientQueue.mutex.Lock()
localSize = websocketConnectionContext.toClientQueue.queueSize
websocketConnectionContext.toClientQueue.mutex.Unlock()
if localSize > MAX_MESSAGES_TO_CLIENT_QUEUE {
gkErr = gkerr.GenGkErr("messageToClient queue overflow, dropping message", nil, ERROR_ID_MESSAGE_TO_CLIENT_QUEUE_OVERFLOW)
gklog.LogGkErr("", gkErr)
} else {
websocketConnectionContext.toClientQueue.mutex.Lock()
websocketConnectionContext.toClientQueue.queueSize += 1
websocketConnectionContext.toClientQueue.mutex.Unlock()
websocketConnectionContext.toClientQueue.messagesChan <- messageToClient
}
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:30,代码来源:queueMessage.go
示例7: runQueue
func (websocketConnectionContext *websocketConnectionContextDef) runQueue() {
var done bool
done = false
for !done {
var messageToClient *message.MessageToClientDef
select {
case messageToClient = <-websocketConnectionContext.toClientQueue.messagesChan:
case done = <-websocketConnectionContext.toClientQueue.doneChan:
}
if !done {
gklog.LogTrace("got message to send: " + messageToClient.Command)
select {
case websocketConnectionContext.messageToClientChan <- messageToClient:
case done = <-websocketConnectionContext.toClientQueue.doneChan:
}
if !done {
websocketConnectionContext.toClientQueue.mutex.Lock()
websocketConnectionContext.toClientQueue.queueSize -= 1
websocketConnectionContext.toClientQueue.mutex.Unlock()
}
}
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:25,代码来源:queueMessage.go
示例8: checkTokenExpire
// purge any expired tokens
func checkTokenExpire() {
expireTime := time.Now().Add(time.Duration(-1) * _tokenExpiry)
for k, v := range _tokenMap {
if expireTime.After(v.createdDate) {
gklog.LogTrace(fmt.Sprintf("removing map entry (timeout) k: %+v v: %+v", k, v))
delete(_tokenMap, k)
}
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:11,代码来源:tempTokens.go
示例9: NewTemplate
func NewTemplate(templateDir string, templateName string) (*TemplateDef, *gkerr.GkErrDef) {
var gkTemplate *TemplateDef = new(TemplateDef)
gkTemplate.tmpl = template.New(templateName)
var file *os.File
var templateListFileName string
var err error
templateListFileName = templateDir + string(os.PathSeparator) + templateName + ".txt"
file, err = os.Open(templateListFileName)
if err != nil {
return nil, gkerr.GenGkErr("os.Open", err, ERROR_ID_OPEN_TEMPLATE_LIST)
}
defer file.Close()
var br *bufio.Reader
localFileNames := make([]string, 0, 0)
br = bufio.NewReader(file)
for {
var line string
line, err = br.ReadString('\n')
line = strings.Trim(line, "\r\n\t ")
if line != "" {
localFileNames = append(localFileNames, templateDir+string(os.PathSeparator)+line)
}
if err != nil {
if err == io.EOF {
break
}
return nil, gkerr.GenGkErr("br.ReadString", err, ERROR_ID_READ_TEMPLATE_LIST)
}
}
// localFileNames = make([]string, len(fileNames), len(fileNames))
// for i := 0; i < len(fileNames); i++ {
// localFileNames[i] = templateDir + string(os.PathSeparator) + fileNames[i] + ".html"
// }
gklog.LogTrace(fmt.Sprintf("localFileNames: %+v", localFileNames))
_, err = gkTemplate.tmpl.ParseFiles(localFileNames...)
if err != nil {
return nil, gkerr.GenGkErr("tmpl.ParseFiles", err, ERROR_ID_PARSE_FILES)
}
return gkTemplate, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:55,代码来源:gkTmpl.go
示例10: CheckToken
// check if the token / userName is valid
func CheckToken(token string, userName string) bool {
_tokenMapMutex.Lock()
defer _tokenMapMutex.Unlock()
checkTokenExpire()
var tokenEntry tokenEntryDef
var ok bool
tokenEntry, ok = _tokenMap[token]
gklog.LogTrace(fmt.Sprintf("check map entry k: %+v v: %+v", token, ok))
if ok {
gklog.LogTrace(fmt.Sprintf("check map entry k: %+v v: %+v", token, tokenEntry))
if tokenEntry.userName == userName {
return true
}
}
return false
}
开发者ID:gk-turnip,项目名称:server,代码行数:21,代码来源:tempTokens.go
示例11: ServeHTTP
func (httpContext *httpContextDef) ServeHTTP(res http.ResponseWriter, req *http.Request) {
if _gameTemplate == nil {
gklog.LogError("missing call to gameInit")
}
path := req.URL.Path
gklog.LogTrace(req.Method)
gklog.LogTrace(path)
if req.Method == _methodGet || req.Method == _methodPost {
if gknet.RequestMatches(path, _gameRequest) {
httpContext.handleGameRequest(res, req)
} else {
http.NotFound(res, req)
}
} else {
http.NotFound(res, req)
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:20,代码来源:httpContext.go
示例12: setAllAvatars
func (fieldContext *FieldContextDef) setAllAvatars(sessionId string, fieldObject *fieldObjectDef) {
var messageToClient *message.MessageToClientDef = new(message.MessageToClientDef)
messageToClient.Command = message.SetSvgReq
messageToClient.JsonData = []byte(fmt.Sprintf("{ \"id\": \"%s\", \"x\": %d, \"y\": %d, \"z\": %d }", fieldObject.id, fieldObject.isoXYZ.X, fieldObject.isoXYZ.Y, fieldObject.isoXYZ.Z))
var singleSession *ses.SingleSessionDef
singleSession = fieldContext.sessionContext.GetSessionFromId(sessionId)
var podId int32 = singleSession.GetCurrentPodId()
for _, websocketConnectionContext := range fieldContext.podMap[podId].websocketConnectionMap {
gklog.LogTrace("compare session " + websocketConnectionContext.sessionId + " " + sessionId)
if websocketConnectionContext.sessionId != sessionId {
gklog.LogTrace("Trace about to queue up move command")
fieldContext.queueMessageToClient(websocketConnectionContext.sessionId, messageToClient)
}
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:20,代码来源:handleSetSvgReq.go
示例13: purgeOldTokenEntries
func (tokenContext *tokenContextDef) purgeOldTokenEntries() {
tokenContext.tokenMutex.Lock()
defer tokenContext.tokenMutex.Unlock()
for tokenId, tokenEntry := range tokenContext.tokenMap {
if tokenEntry.createdDate.Add(time.Second * _tokenTimeoutSeconds).Before(time.Now()) {
gklog.LogTrace(fmt.Sprintf("purge token entry: %+v", tokenEntry))
delete(tokenContext.tokenMap, tokenId)
}
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:11,代码来源:tokenContext.go
示例14: ServeHTTP
func (loginConfig *loginConfigDef) ServeHTTP(res http.ResponseWriter, req *http.Request) {
if _loginTemplate == nil {
gklog.LogError("missing call to loginInit")
}
path := req.URL.Path
gklog.LogTrace(req.Method)
gklog.LogTrace(path)
if req.Method == _methodGet || req.Method == _methodPost {
if gknet.RequestMatches(path, _loginServer) {
handleLogin(loginConfig, res, req)
} else {
http.NotFound(res, req)
}
} else {
http.NotFound(res, req)
}
}
开发者ID:gk-turnip,项目名称:server,代码行数:21,代码来源:loginServerHandler.go
示例15: handleSetAvatarSvgReq
func (fieldContext *FieldContextDef) handleSetAvatarSvgReq(messageFromClient *message.MessageFromClientDef) *gkerr.GkErrDef {
var gkErr *gkerr.GkErrDef
var err error
var setSvg setSvgDef
gklog.LogTrace("json raw: " + string(messageFromClient.JsonData))
err = json.Unmarshal(messageFromClient.JsonData, &setSvg)
if err != nil {
gkErr = gkerr.GenGkErr("json.Unmarshal", err, ERROR_ID_JSON_UNMARSHAL)
return gkErr
}
var singleSession *ses.SingleSessionDef
singleSession = fieldContext.sessionContext.GetSessionFromId(messageFromClient.SessionId)
var podId int32 = singleSession.GetCurrentPodId()
var fieldObject *fieldObjectDef
var ok bool
fieldObject, ok = fieldContext.podMap[podId].avatarMap[setSvg.Id]
if ok {
var cord int
cord, _ = strconv.Atoi(setSvg.X)
fieldObject.isoXYZ.X = int16(cord)
cord, _ = strconv.Atoi(setSvg.Y)
fieldObject.isoXYZ.Y = int16(cord)
cord, _ = strconv.Atoi(setSvg.Z)
fieldObject.isoXYZ.Z = int16(cord)
gklog.LogTrace("one")
fieldContext.setAllAvatars(messageFromClient.SessionId, fieldObject)
} else {
gkErr = gkerr.GenGkErr("move object", nil, ERROR_ID_COULD_NOT_FIND_OBJECT_TO_MOVE)
gklog.LogGkErr("", gkErr)
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:39,代码来源:handleSetSvgReq.go
示例16: AddNewToken
// add a new token / userName to the list of tokens
func AddNewToken(token string, userName string) {
_tokenMapMutex.Lock()
defer _tokenMapMutex.Unlock()
checkTokenExpire()
var tokenEntry tokenEntryDef
tokenEntry.userName = userName
tokenEntry.createdDate = time.Now()
_tokenMap[token] = tokenEntry
gklog.LogTrace(fmt.Sprintf("add map entry k: %+v v: %+v", token, tokenEntry))
}
开发者ID:gk-turnip,项目名称:server,代码行数:14,代码来源:tempTokens.go
示例17: Build
func (gkTemplate *TemplateDef) Build(buildData interface{}) *gkerr.GkErrDef {
gkTemplate.dataBuffer = bytes.NewBuffer(make([]byte, 0, 0))
var err error
gklog.LogTrace(fmt.Sprintf("buildData: %+v", buildData))
err = gkTemplate.tmpl.ExecuteTemplate(gkTemplate.dataBuffer, "main", buildData)
if err != nil {
return gkerr.GenGkErr("tmpl.ExecuteTemplate", err, ERROR_ID_EXECUTE_TEMPLATE)
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:13,代码来源:gkTmpl.go
示例18: reAddAvatarBySessionId
// put the avatar back
func (fieldContext *FieldContextDef) reAddAvatarBySessionId(sessionId string, newPodId int32) *gkerr.GkErrDef {
gklog.LogTrace("re adding an avatar by session id")
var gkErr *gkerr.GkErrDef
for _, fieldObject := range fieldContext.podMap[newPodId].avatarMap {
if fieldObject.sourceSessionId == sessionId {
websocketConnectionContext := fieldContext.podMap[newPodId].websocketConnectionMap[sessionId]
gklog.LogTrace(fmt.Sprintf("reAddAvatarBySessionId new destination: %d,%d,%d", fieldObject.isoXYZ.X, fieldObject.isoXYZ.Y, fieldObject.isoXYZ.Z))
gkErr = fieldContext.sendSingleAvatarObject(websocketConnectionContext, fieldObject)
if gkErr != nil {
return gkErr
}
// for _, websocketConnectionContext := range fieldContext.podMap[newPodId].websocketConnectionMap {
// if (sessionId == websocketConnectionContext.sessionId) {
// }
// }
}
}
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:24,代码来源:fieldContext.go
示例19: handleSaveTerrainEditReq
func (fieldContext *FieldContextDef) handleSaveTerrainEditReq(messageFromClient *message.MessageFromClientDef) *gkerr.GkErrDef {
var saveTerrainEditReq saveTerrainEditReqDef
var gkErr *gkerr.GkErrDef
var err error
var singleSession *ses.SingleSessionDef
singleSession = fieldContext.sessionContext.GetSessionFromId(messageFromClient.SessionId)
gklog.LogTrace("handleSaveTerrainEditReq")
gklog.LogTrace(fmt.Sprintf("singleSession: %+v", singleSession))
gklog.LogTrace(fmt.Sprintf("messageFromClient.JsonData: %s", string(messageFromClient.JsonData)))
err = json.Unmarshal(messageFromClient.JsonData, &saveTerrainEditReq)
if err != nil {
gkErr = gkerr.GenGkErr("json.Unmarshal", err, ERROR_ID_JSON_UNMARSHAL)
return gkErr
}
for k, v := range saveTerrainEditReq.TerrainMapMap {
gklog.LogTrace(fmt.Sprintf("k: %+v", k))
gklog.LogTrace(fmt.Sprintf("v: %+v", v))
// v has:
// x, y, zlist, terrainName, Field
}
//
// gkErr = fieldContext.persistenceContext.SetSaveTerrainEdit(singleSession.GetUserName(), saveTerrainEditReq.PrefName, saveTerrainEditReq.PrefValue)
// if gkErr != nil {
// // inserting user preferences is non critical
// // so just log the error
// gklog.LogGkErr("fieldContext.persistenceContext.SetSaveTerrainEdit", gkErr)
// }
return nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:37,代码来源:handleSaveTerrainEditReq.go
示例20: NewFieldContext
func NewFieldContext(avatarSvgDir string, terrainSvgDir string, sessionContext *ses.SessionContextDef, persistenceContext *persistence.PersistenceContextDef) (*FieldContextDef, *gkerr.GkErrDef) {
var fieldContext *FieldContextDef = new(FieldContextDef)
var gkErr *gkerr.GkErrDef
fieldContext.avatarSvgDir = avatarSvgDir
fieldContext.terrainSvgDir = terrainSvgDir
fieldContext.sessionContext = sessionContext
fieldContext.persistenceContext = persistenceContext
fieldContext.WebsocketOpenedChan = make(chan WebsocketOpenedMessageDef)
fieldContext.WebsocketClosedChan = make(chan WebsocketClosedMessageDef)
fieldContext.MessageFromClientChan = make(chan *message.MessageFromClientDef)
var podList []database.DbPodDef
podList, gkErr = persistenceContext.GetPodsList()
if gkErr != nil {
return nil, gkErr
}
fieldContext.podMap = make(map[int32]*podEntryDef)
for _, dbPod := range podList {
gklog.LogTrace(fmt.Sprintf("populate pod %+v", dbPod))
var podEntry *podEntryDef = new(podEntryDef)
podEntry.podId = dbPod.Id
podEntry.title = dbPod.Title
podEntry.websocketConnectionMap = make(map[string]*websocketConnectionContextDef)
podEntry.avatarMap = make(map[string]*fieldObjectDef)
podEntry.objectMap = make(map[string]*fieldObjectDef)
podEntry.terrainJson, gkErr = fieldContext.newTerrainMap(podEntry.podId)
if gkErr != nil {
return nil, gkErr
}
fieldContext.podMap[podEntry.podId] = podEntry
}
fieldContext.savedChatMutex = new(sync.Mutex)
fieldContext.savedChat = list.New()
// fieldContext.terrainMap, gkErr = fieldContext.newTerrainMap(fieldContext, fieldContext.terrainSvgDir, fieldContext.persistenceContext)
// if gkErr != nil {
// return nil, gkErr
// }
return fieldContext, nil
}
开发者ID:gk-turnip,项目名称:server,代码行数:46,代码来源:fieldContext.go
注:本文中的gk/gklog.LogTrace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论