コード例 #1
0
  /**
   * 邀请好友
   *
   * @param args
   */
  @RPCReponse("e_invitation")
  public void invitation(LogicRequest args) {
    Long uid; // 用户id
    Long rid; // 房间id
    List<String> list; // 好友id列表
    List<String> onlinelist = new ArrayList<String>();
    try {
      InvitationOp op = ObjectBeanUtil.JACKSON.readValue(args.getData(), InvitationOp.class);
      if (op != null) {
        uid = op.getUid();
        rid = op.getRid();
        list = op.getList();
        String uName = "";
        String roomName = "";
        UserFundDetails uinfo = LobbyUserHelper.getUserInfo(uid);
        uName = uinfo.getNn();
        Rooms r = LocalCache.ROOMS.get(rid.toString());
        if (r != null) {
          roomName = r.getRn();
        }
        InvitationsRoomVo iRV =
            new InvitationsRoomVo(
                Definition.INVITATIONS, Definition.SUCCESS_CODE, rid, roomName, uid, uName);
        System.out.println(list);
        if (list != null && list.size() > 0) {
          Iterator itr = list.iterator();
          while (itr.hasNext()) {
            Long otherId = Long.valueOf(itr.next().toString());
            if (LobbyUserHelper.isLobby(otherId)) { // 大厅中存在该用户

              // 建立消息通道

              onlinelist.add(otherId.toString());

              // 存储消息邮件
              UserMessageHelper.Message message = new UserMessageHelper.Message();
              message.setTitle("牌局邀请");
              message.setContent(iRV.toString());
              message.setType(MessageManager.Type.INT.getValue());
              message.setSubtype(MessageManager.Subtype.interaction.getValue());
              UserMessageHelper.insertUserMessage(otherId, message);

              // MessageSendUtil.sendAddUserMsgTipToUser(otherId);//更新TOP菜单栏消息提示
              LobbyUserHelper.sendMsgTips(uid);
            }
          }

          LogicChannelUtil.sendToTargets(iRV, onlinelist);
        }
      }
    } catch (Exception e) {
      LOGGER.error("", e);
      e.printStackTrace();
    }
  }
コード例 #2
0
  @Override
  @RPCReponse("e_fastplay")
  public ResultVo Quick_Game(LogicRequest args) {
    ResultVo vo = null;

    LobbyUserHelper.checkStopGame();
    ServerstopResultVo srv = (new ServerStopTask()).isServerStop();
    if (srv == null) {
      QuickVo op = null;
      try {
        op = ObjectBeanUtil.JACKSON.readValue(args.getData(), QuickVo.class);
      } catch (JsonParseException e) {
        // TODO 自动生成的 catch 块
        e.printStackTrace();
      } catch (JsonMappingException e) {
        // TODO 自动生成的 catch 块
        e.printStackTrace();
      } catch (IOException e) {
        // TODO 自动生成的 catch 块
        e.printStackTrace();
      }
      QuickJoinRooms jr = new QuickJoinRooms();
      return jr.task(op);
    } else {
      return srv;
    }
  }
コード例 #3
0
  @RPCReponse("e_changetable")
  public ResultVo changeTable(LogicRequest args) {
    // TODO 自动生成的方法存根
    String sessionId = args.getSession();
    LobbyUserHelper.sendJewelBoxMoneyFromData(sessionId);

    ResultVo vo = (new ChangeTableTask()).Task(args);
    return vo;
  }
コード例 #4
0
  /**
   * 邀请好友列表
   *
   * @param args
   * @return
   */
  @RPCReponse("e_invitation_list")
  public ResultVo invitationlist(LogicRequest args) {
    ResultVo vo = null;
    Long uid = null;
    try {
      FlashLoginOp op = ObjectBeanUtil.JACKSON.readValue(args.getData(), FlashLoginOp.class);
      if (op != null) {
        uid = op.getFbid();
      }

      if (uid == null || uid <= 0) {
        vo = new ResultVo(Definition.GET_INVITATIONS_LIST, Definition.ARG_CODE);
        return vo;
      }

      List<Invitations> relations = LobbyUserHelper.getInvitationUser(uid.toString());
      vo = new ResultVo(Definition.GET_INVITATIONS_LIST, Definition.SUCCESS_CODE, relations);

    } catch (Exception e) {
      vo = new ResultVo(Definition.GET_INVITATIONS_LIST, Definition.UNKNOW_CODE);
    }
    return vo;
  }
コード例 #5
0
 @RPCReponse("e_getjewelchips")
 public void getJewelBoxChips(LogicRequest args) {
   // TODO 自动生成的方法存根
   String sessionId = args.getSession();
   LobbyUserHelper.sendJewelBoxMoneyFromData(sessionId);
 }
コード例 #6
0
  @Override
  @RPCReponse("e_login")
  public LoginVo login(LogicRequest args) {
    // ConcurrentHashMap<Long, PlayerInfoInSupremeRoom> inRoomQueue =
    // CarCache.PLAYER_INFO_IN_SUPREMEROOM;
    // System.out.println(inRoomQueue);
    FlashLoginOp rpcMap = null;
    try {
      rpcMap = ObjectBeanUtil.JACKSON.readValue(args.getData(), FlashLoginOp.class);
    } catch (IOException e) {
      LOGGER.warn("", e);
    }
    // Users uf = usersDao.get(rpcMap.getFbid());

    /*
     * UserFundInfoVo users = LocalCache.USER_FUNDS.get(rpcMap.getFbid());
     * if (users == null) {// 从本地调试或手机端登录的账,这里进入系统缓存 String imgurl = "";
     *
     * imgurl = LobbyUserHelper.getFigureurl(rpcMap.getFbid(), null);
     *
     * UserFund userFund = LobbyUserHelper.getUserFund(rpcMap.getFbid());//
     * userFundDao.get(rpcMap.getFbid()); if (userFund != null) {
     * userFund.setImgurl(imgurl); users =
     * LobbyUserHelper.saveUserInfoToCache(userFund, false);
     *
     * } }
     */
    String userNick = null;
    RedisLogin redis = SpringUtils.getBean(RedisLogin.class);
    String uname = redis.hget(USER_INFO_CECHED_PRDFIX + rpcMap.getFbid(), "name");

    if (uname == null) userNick = "joker";
    else userNick = uname;

    List<TodayMatchs> matchs = null; // MatchService.getTodayMatchs();// 今日大赛
    // 返回值
    /**
     * String cmd, long code, int isn, int isg, double gchips, long sessionid, String name, int lds,
     * double ldcs, double ldms, List<TodayMatchs> matchs
     */
    LoginVo vo =
        new LoginVo(
            Definition.LOGIN,
            Definition.SUCCESS_CODE,
            LobbyUserHelper.isLoginNewUser(rpcMap.getFbid()),
            userNick,
            matchs);
    String key = "";
    boolean isenablerk =
        true; // OptionUtils.convertToBoolean(OptionUtils.getDefaultOption("option.api.appkey.reload.enable",
    // "true"));
    if (isenablerk) { // 重连的时候需要重置sign
      key = UUID.randomUUID().toString();
      // LobbyUserHelper.updateUserSign(fbId, key);
    }
    vo.setKey(key);

    // 获取用户sessionid
    String sessionId = args.getSession();
    // 获取用户所在的映射服务器
    String targetMapping = redis.hget(RedisKeys.KEY_LOGIN_MAPPING, sessionId);

    if (null == targetMapping) // 没有登陆
    {
      String proxyId = LogicPropertyUtil.getString("proxy.id", "proxy1");
      String keyProxyMap = String.format(RedisKeys.KEY_LOGIN_PROXY, proxyId);
      // 保存映射
      redis.hset(
          RedisKeys.KEY_LOGIN_MAPPING,
          sessionId,
          String.format("%s@%s", proxyId, args.getChannelId()));
      redis.hset(keyProxyMap, args.getSession(), args.getChannelId());

    } else // 已经登陆
    {

      boolean isPlayGame = LobbyUserHelper.isPlay(Long.valueOf(sessionId)); // TODO
      // 是否在游戏当中

      String[] mappingInfo = targetMapping.split("@");

      String targetRouter = mappingInfo[0];
      String targetChannelId = mappingInfo[1];
      if (isPlayGame) // 正在玩游戏
      {
        // TODO 通知当前通信的客户端下线
        vo = new LoginVo(Definition.LOGIN, Definition.REPEAT_CODE);
        return vo;

      } else {
        LoginVo event = new LoginVo(Definition.OTHERPLAYLOGIN, Definition.REPEAT_CODE);

        // 踢出前一个正在操作的对象
        ProxyResponse response = new ProxyResponse();
        response.setChannelId(targetChannelId);
        response.setSession(sessionId);
        response.setReponse(event);
        response.setIsRoute(1);
        response.setProxy(targetRouter);
        Event responseEvent =
            io.nadron.client.event.Events.dataInEvent(ProxyResponseBuilder.build(response));
        LogicChannelUtil.writeObjectToChannel(responseEvent);
        // 保存映射关系
        String proxyId = LogicPropertyUtil.getString("proxy.id");
        String keyProxyMap = String.format(RedisKeys.KEY_LOGIN_PROXY, proxyId);
        // 保存映射
        redis.hset(
            RedisKeys.KEY_LOGIN_MAPPING,
            sessionId,
            String.format("%s@%s", proxyId, args.getChannelId()));
        redis.hset(keyProxyMap, args.getSession(), args.getChannelId());
      }
      LobbyUserHelper.deleteAllUserInRoom(sessionId);
    }
    LobbyUserHelper.sendJewelBoxMoneyFromData(sessionId);

    // 发送公告
    Notices n = LobbyMsgHelper.getLastNotice();
    if (n != null && System.currentTimeMillis() < n.getEndTime().getTime()) {
      MsgSendVo msgvo =
          new MsgSendVo(
              Definition.NOTICES,
              n.getContent(),
              DateUtils.dateToString(
                  new Date(n.getOperatedTime().getTime()), DateUtils.PATTERN_YMDHMS));
      // 发送
      LogicChannelUtil.sendToTargets(msgvo, Lists.newArrayList(sessionId));
    }
    //
    return vo;
  }