本文整理汇总了Golang中gk/game/ses.SingleSessionDef.GetSessionId方法的典型用法代码示例。如果您正苦于以下问题:Golang SingleSessionDef.GetSessionId方法的具体用法?Golang SingleSessionDef.GetSessionId怎么用?Golang SingleSessionDef.GetSessionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gk/game/ses.SingleSessionDef
的用法示例。
在下文中一共展示了SingleSessionDef.GetSessionId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
}