Exemplo n.º 1
0
 /**
  * 被用户拒绝
  *
  * @param friendId
  */
 public TipUtil delFriend(int friendId) {
   TipUtil tip = new TipUtil(ProcotolType.FRIEND_RESP);
   tip.setFailTip("del fail");
   //		logger.info("删除好友 : " + friendId);
   Friend fr = friMgr.get(friendId);
   if (fr != null) {
     friMgr.remove(friendId);
     fr.setIsdel((byte) 1);
     List<Friend> roleLst = player.getRelationManager().myFriend();
     //			ArrayList<PlayerCache> roleLst1 = player.getRelationManager()
     //					.randomOnlineUser((byte) 0);
     // **********rms
     RespModuleSet rms = new RespModuleSet(ProcotolType.FRIEND_RESP);
     //			for (Friend frs : roleLst) {
     //				rms.addModule(frs);
     //			}
     //			for (PlayerCache cache : roleLst1) {
     //				rms.addModule(cache);
     //			}
     rms.addModule(fr);
     AndroidMessageSender.sendMessage(rms, player);
     gameDao.getRelationDAO().delFriend(fr);
     // **********rms
     tip.setSuccTip(MessageConst.FRIENT_DEL_S);
   } else {
     if (I18nGreeting.LANLANGUAGE_TIPS == 1) {
       tip.setFailTip("Delete failed.");
     } else {
       tip.setFailTip("删除失败");
     }
   }
   return tip;
 }
Exemplo n.º 2
0
  /** 添加 好友申请 */
  public TipUtil addFriend(int friendId) {
    TipUtil tip = new TipUtil(ProcotolType.FRIEND_RESP);
    if (I18nGreeting.LANLANGUAGE_TIPS == 1) {
      tip.setFailTip("Add failed.");
    } else {
      tip.setFailTip("添加失败");
    }

    //		logger.info("[addFriend]添加好友 : " + friendId);
    if (friMgr.get(friendId) == null) {
      // add friend type = 0
      Friend friend = new Friend();
      friend.setFriendId(friendId);
      friend.setMyId(player.getId());
      friend.setType((byte) 2);
      friend.setAddTime(TimeUtils.nowLong());
      gameDao.getRelationDAO().addFriend(friend);
      friend.setIsdel((byte) 0);
      friMgr.put(friendId, friend);
      //			logger.info("[addFriend]" + MessageConst.FRIENT_ADD_S);
      tip.setSuccTip(MessageConst.FRIENT_ADD_S);
      List<Friend> roleLst = player.getRelationManager().myFriend();
      //			ArrayList<PlayerCache> roleLst1 = player.getRelationManager()
      //					.randomOnlineUser((byte) 0);
      // **********rms
      RespModuleSet rms = new RespModuleSet(ProcotolType.FRIEND_RESP);
      // rms.addModule(friend);
      //			for (Friend role : roleLst) {
      //				rms.addModule(role);
      //			}
      //			for (PlayerCache role : roleLst1) {
      //				rms.addModule(role);
      //			}
      rms.addModule(friend);
      AndroidMessageSender.sendMessage(rms, player);
      // **********rms
      return tip;
    } else {
      Friend friend = friMgr.get(friendId);
      if (friend == null) {
        //				logger.info("好友为空,添加失败");
        if (I18nGreeting.LANLANGUAGE_TIPS == 1) {
          tip.setFailTip("Add failed.Friend doesn't exist. ");
        } else {
          tip.setFailTip("好友为空,添加失败");
        }
        return tip;
      } else {
        //				logger.info("[addFriend]" + MessageConst.FRIENTR_F1);
        friend.setTips(MessageConst.FRIENTR_F1, GameConst.GAME_RESP_FAIL);
        tip.setFailTip(MessageConst.FRIENTR_F1);
        return tip;
      }
    }
  }
Exemplo n.º 3
0
 /**
  * 添加最近用户
  *
  * @param userid
  */
 public void addRecentlyPlayer(int userid) {
   PlayerCharacter pp = World.getInstance().getPlayer(userid);
   if (pp != null) {
     roleMgr.put(userid, pp.getData());
     // rms
     RespModuleSet rms = new RespModuleSet(ProcotolType.FRIEND_RESP);
     rms.addModule(
         MongoServer.getInstance()
             .getLogServer()
             .getPlayerCacheDAO()
             .findPlayerCacheByUserid(pp.getId()));
     AndroidMessageSender.sendMessage(rms, player);
     // rms
   }
 }