Example #1
0
 /// <summary>
 /// 上线
 /// </summary>
 /// <param name="client"></param>
 private void Online(ClientPeer client)
 {
     SingleExecute.Instance.Execute(() =>
     {
         if (!accountCache.IsOnline(client))
         {
             client.Send(OpCode.USER, UserCode.GET_INFO_SRES, -1);//非法登录
             Console.WriteLine("上线---非法登录");
             return;
         }
         int accountId = accountCache.GetId(client);
         if (userCache.isExist(accountId) == false)
         {
             client.Send(OpCode.USER, UserCode.ONLINE_SRES, -2);//没有角色
             Console.WriteLine("上线---没有角色");
             return;
         }
         int userId = userCache.GetId(accountId);
         userCache.Online(client, userId);
         client.Send(OpCode.USER, UserCode.ONLINE_SRES, 0);//上线成功
         Console.WriteLine(string.Format("上线---上线成功,当前在线玩家:{0}人", accountCache.GetOnlineNum()));
     });
 }