本文整理汇总了Golang中gk/game/ses.SingleSessionDef.SetCurrentPodId方法的典型用法代码示例。如果您正苦于以下问题:Golang SingleSessionDef.SetCurrentPodId方法的具体用法?Golang SingleSessionDef.SetCurrentPodId怎么用?Golang SingleSessionDef.SetCurrentPodId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gk/game/ses.SingleSessionDef
的用法示例。
在下文中一共展示了SingleSessionDef.SetCurrentPodId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleNewPodReq
// websocketConnectionContext entry must be moved from old pod to new pod
func (fieldContext *FieldContextDef) handleNewPodReq(messageFromClient *message.MessageFromClientDef) *gkerr.GkErrDef {
var newPodReq newPodReqDef
var gkErr *gkerr.GkErrDef
var err error
err = json.Unmarshal(messageFromClient.JsonData, &newPodReq)
if err != nil {
gkErr = gkerr.GenGkErr("json.Unmarshal", err, ERROR_ID_JSON_UNMARSHAL)
return gkErr
}
var destinationX, destinationY, destinationZ int
destinationX, _ = strconv.Atoi(newPodReq.X)
destinationY, _ = strconv.Atoi(newPodReq.Y)
destinationZ, _ = strconv.Atoi(newPodReq.Z)
var websocketConnectionContext *websocketConnectionContextDef
websocketConnectionContext, gkErr = fieldContext.getWebsocketConnectionContextById(messageFromClient.SessionId)
if gkErr != nil {
return gkErr
}
var singleSession *ses.SingleSessionDef
singleSession = fieldContext.sessionContext.GetSessionFromId(websocketConnectionContext.sessionId)
var oldPodId int32 = singleSession.GetCurrentPodId()
var newPodId int64
newPodId, _ = strconv.ParseInt(newPodReq.PodId, 10, 32)
if (fieldContext.isPodIdValid(int32(newPodId))) && (oldPodId != int32(newPodId)) {
gkErr = fieldContext.moveAllAvatarBySessionId(messageFromClient.SessionId, oldPodId, int32(newPodId), int16(destinationX), int16(destinationY), int16(destinationZ))
if gkErr != nil {
gklog.LogGkErr("", gkErr)
return gkErr
}
delete(fieldContext.podMap[oldPodId].websocketConnectionMap, messageFromClient.SessionId)
singleSession.SetCurrentPodId(int32(newPodId))
fieldContext.podMap[int32(newPodId)].websocketConnectionMap[messageFromClient.SessionId] = websocketConnectionContext
gkErr = fieldContext.uploadNewPodInfo(websocketConnectionContext, int32(newPodId))
if gkErr != nil {
gklog.LogGkErr("", gkErr)
return gkErr
}
gkErr = fieldContext.reAddAvatarBySessionId(messageFromClient.SessionId, int32(newPodId))
if gkErr != nil {
gklog.LogGkErr("", gkErr)
return gkErr
}
} else {
gkErr = gkerr.GenGkErr(fmt.Sprintf("invalid podId: %d", newPodId), nil, ERROR_ID_INVALID_POD_ID)
gklog.LogGkErr("", gkErr)
return gkErr
}
return nil
}