COK2主要流程
2019-08-19 13:59:54 4 举报
COK2
作者其他创作
大纲/内容
InternalAsyncRunner
SavePlayerOperation
GcMessageDispatcher
schedule
PlayerMessageExecutor
使用rId加载Role数据,会有很多张表,全部加载出来。
GcPlayerInfo
QueuedMessageExecutor
在mainWork里检查,如果不存在则走加载或者创建流程,否则就直接把Session关联到Player上,如果有老的Session,则关闭
run
MainWorker
创建
查询玩家是否在库里,以及状态(正常或者未激活两种)select `state` from `player_data` where `id`=rid
CgLogin
1. 校验md52. 检查前端版本3. 检查是否封号4. 把前端发过来的deviceid、国家、语言、平台等存在player里
startServices
清理数据,并且让踢它的玩家登录
LogoutState.logouted
GcTopHandler
啥都不做
GlobalMessageExecutor
如果是disconnecting
状态改为logoutgamingLogout
PlayerInternalMessage imsg??
状态改为RECONNECTING
SingleThreadTaskWorker<Object>
Netty
主线程
SimpleLoginOperation发送:uid、rid
mainWork
GamingState.disconnect
SingleThreadWorker
2.2.2.1CreateRoleOperation主要还是rid和uid
WorldWorker worldWorker
异步任务线程池
1. 设置playerid为rid、及uid2. 检查player是否已经登录过2.1 如果已经登录过,则记录player到oldplayer身上,然后让oldplayer下线2.2 反之,则继续执行登录流程:ConnectedState的logined:2.2.1 切换ConnectedState为LOGINED2.2.2 加入到playerService的playerMap里2.2.2.1 如果是新玩家,则创建role2.2.2.2 如果是老玩家,则加载
必须是LogoutState
EnteringState.disconnect
等待
DisconnectedState.disconnected
checkPlayerSession
InternalMessage imsg
否则
LoadPlayerOperation
onReplay
创建并初始化Player:绑定Session设置onLineState为InitStatePlayerSessionServiceImpl里加入player执行InitState的Connect,会把onLineState变成ConnectedState
LogoutState.disconnect
ReplayOperation
Tick
如果是服务器主动断开
否则,如果网络已经断开
针对老连接
internalStartService
QueuedMessageExecutor msgExecutor
NetMessage nmsg
如果加载数据了
leaveWorld
1. 通过mainData来addrole(里面有大量逻辑,包括DB异步操作),如果失败还需要再通过异步线程把这一条删了2. worldSrv.addRoleToWorld3. 执行SavePlayerOperation,去DB里save一下4. UpdateRoleDataToCenterServerOperation5. 执行LoginedState的created:playerSrv.loadPlayer。
SavePlayerOperationOnLogout
SessionCloseMsg
initRuntime
把状态改成disconnected
1. playerSrv.initPlayer2. 执行LoginedState的loaded:2.1 LoginedState转为EnteringState2.2 初始化消息接收器player.initMsgExecutor2.3 设置连续登录2.4 再次初始化device等信息到player
状态改为logout
LogoutState.logout
channelInactive
forceRemove
LogoutState.leaveWorld
SessionConnectMsg
1. 通过uid生成默认名字,并且保证不重名2. 初始化player各个模块3. insert into `player_data`(发回给mainWork)4. 如果有问题还要delete from `player_data`
初始化
2.2.2.2LoadPlayerOperation
ConnectedState.disconnect
checkAndSend
如果是reconnecting
完成
execute
CgEnterMap
CgReconnect
asyncMsgSender
状态改为GAMING
CgReplay
WorldServiceImpl.world
GlobalMessageExecutor globalMsgExec
AsyncOperationServiceImpl
IMessage
loginSrv.logouted
disconnect
ReconnectingState.disconnect
MainWorker mainWorker
GlobalMessageExecutor msgExec
finish
WorldScheduler
针对重连的连接
MessageDispatcher messageDispatcher
AsyncMessageSender
状态改为DISCONNECTED
ScheduledThreadPoolExecutor
InternalRunner
PlayerDisconnectSession
放在消息队列,在player的tick里执行
MessageExecutor msgExec
Player p
发送:是否有数据、数据状态
reconnect
ThreadPoolScheduleService
LoadOrCreateRole
Player
如果出错
LoginedState.disconnect
execute(AsyncOperation oper)
tick
player.close
mainData
收藏
0 条评论
下一页