Esempio n. 1
0
        /// <summary>
        /// 上线的处理
        /// </summary>
        /// <param name="client"></param>
        private void onOnline(MobaClient client)
        {
            int accId    = accountCache.GetId(client);
            int playerId = playerCache.GetId(accId);

            //防止重复在线
            //if (playerCache.IsOnline(client))
            //    return;
            //上线
            playerCache.Online(client, playerId);

            #region 每次上线的时候 要通知好友 显示在线状态

            PlayerModel model = playerCache.GetModel(client);
            if (model != null)
            {
                MobaClient tempClient = null;
                string[]   friends    = model.FriendIdList.Split(',');
                foreach (string item in friends)
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }
                    int id = int.Parse(item);
                    if (!playerCache.IsOnline(id))
                    {
                        continue;
                    }
                    tempClient = playerCache.GetClient(id);
                    Send(tempClient, OpCode.PlayerCode, OpPlayer.FriendOnline, 0, "此玩家上线", model.Id);
                }
            }
            #endregion

            PlayerDto dto = toDto(playerCache.GetModel(playerId));

            //发送
            Send(client, OpCode.PlayerCode, OpPlayer.Online, 0, "上线成功", JsonMapper.ToJson(dto));
        }