/// <summary>
        ///     Handle the login of client.
        /// </summary>
        internal void StartSession(Account account, string ipAddress, string deviceModel, byte[] sessionId, int proxyId)
        {
            if (account.Session != null)
            {
                NetAccountSessionManager.TryRemove(account.Session.SessionId);

                account.Session.SendMessage(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, new UnbindServerMessage());
                account.Session.Destruct();
                account.SetSession(null);
            }

            NetAccountSession session = NetAccountSessionManager.Create(account, sessionId);

            account.SetSession(session);
            account.SessionStarted(LogicTimeUtil.GetTimestamp(), ipAddress, deviceModel);
            session.SetServiceNodeId(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, proxyId);

            LoginClientOkMessage loginClientOkMessage = new LoginClientOkMessage();

            loginClientOkMessage.SetAccountId(account.Id);
            loginClientOkMessage.SetHomeId(account.Id);
            loginClientOkMessage.SetPassToken(account.PassToken);
            loginClientOkMessage.SetAccountCreatedDate(account.AccountCreatedDate);
            loginClientOkMessage.SetSessionCount(account.TotalSessions);
            loginClientOkMessage.SetPlayTimeSeconds(account.PlayTimeSecs);

            session.SendMessage(NetUtils.SERVICE_NODE_TYPE_PROXY_CONTAINER, loginClientOkMessage);
        }
        /// <summary>
        ///     Called when a <see cref="ServerUnboundMessage"/> is received.
        /// </summary>
        internal void ServerUnboundMessageReceived(ServerUnboundMessage message)
        {
            byte[] sessionId = message.GetSessionId();

            if (NetAccountSessionManager.TryRemove(sessionId, out NetAccountSession session))
            {
                session.Account.EndSession();
                session.Account.SetSession(null);
                session.SaveAccount();
                session.Destruct();
            }
        }
        /// <summary>
        ///     Called when a <see cref="ExecuteAdminCommandMessage"/> is received.
        /// </summary>
        private void ExecuteAdminCommandMessageReceived(ExecuteAdminCommandMessage message)
        {
            byte[] sessionId = message.GetSessionId();

            if (NetAccountSessionManager.TryGet(sessionId, out NetAccountSession session))
            {
                AdminCommand adminCommand = message.RemoveDebugCommand();

                if (adminCommand.GetServiceNodeType() == ServiceCore.ServiceNodeType)
                {
                    switch (adminCommand.GetCommandType())
                    {
                    default:
                        Logging.Print(string.Format("executeAdminCommandMessageReceived unknown debug command received ({0})", adminCommand.GetCommandType()));
                        break;
                    }
                }
                else
                {
                    Logging.Print(string.Format("executeAdminCommandMessageReceived invalid debug command received ({0})", adminCommand.GetCommandType()));
                }
            }
        }
Beispiel #4
0
 /// <summary>
 ///     Initializes the network part.
 /// </summary>
 internal static void InitNetwork()
 {
     NetAccountSessionManager.Initialize();
 }