Search in sources :

Example 1 with UserVo

use of com.code.server.constant.response.UserVo in project summer by foxsugar.

the class GameUserService method getUserMessage.

public int getUserMessage(KafkaMsgKey msgKey) {
    UserBean userBean = userRedisService.getUserBean(msgKey.getUserId());
    if (userBean == null) {
        return ErrorCode.YOU_HAVE_NOT_LOGIN;
    }
    String roomId = userRedisService.getRoomId(msgKey.getUserId());
    UserVo userVo = userBean.toVo();
    userVo.setRoomId(roomId);
    ResponseVo vo = new ResponseVo("userService", "getUserMessage", userVo);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : UserVo(com.code.server.constant.response.UserVo) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 2 with UserVo

use of com.code.server.constant.response.UserVo in project summer by foxsugar.

the class UserBean method toVo.

@Override
public UserVo toVo() {
    UserVo userVo = new UserVo();
    userVo.setId(this.id);
    // required
    userVo.setUsername(this.username);
    // required
    userVo.setImage(this.image);
    // required
    userVo.setSeatId(this.seatId);
    // required
    userVo.setAccount(this.account);
    // required
    userVo.setIpConfig(this.ipConfig);
    // required
    userVo.setMoney(this.money);
    // required
    userVo.setRoomId(this.roomId);
    // required
    userVo.setVip(this.vip);
    // required
    userVo.setUuid(this.uuid);
    // required
    userVo.setOpenId(this.openId);
    // required
    userVo.setSex(this.sex);
    userVo.setReferee(this.referee);
    userVo.setUserInfo(this.userInfo);
    userVo.setGold(this.getGold());
    userVo.setCoord(coord);
    return userVo;
}
Also used : UserVo(com.code.server.constant.response.UserVo)

Example 3 with UserVo

use of com.code.server.constant.response.UserVo in project summer by foxsugar.

the class ReconnService method reconnection.

public static int reconnection(String roomId, long userId) {
    AllMessage allMessage = new AllMessage();
    allMessage.setExist(false);
    RoomInfo roomInfo = (RoomInfo) RoomManager.getRoom(roomId);
    if (roomInfo != null) {
        allMessage.setExist(true);
        List<UserVo> userList = new ArrayList<>();
        allMessage.setRoom(getRoomInfo(roomInfo));
        allMessage.setBanker(roomInfo.getBankerId());
        allMessage.setCurGameNumber(roomInfo.getCurGameNumber());
        allMessage.setUserScores(roomInfo.getUserScores());
        allMessage.setUserStatus(roomInfo.getUserStatus());
        // 圈数
        allMessage.setCircleNum(roomInfo.getCurCircle());
        allMessage.getLaZhuang().putAll(roomInfo.getLaZhuang());
        allMessage.getLaZhuangStatus().putAll(roomInfo.getLaZhuangStatus());
        for (UserBean userBean : RedisManager.getUserRedisService().getUserBeans(roomInfo.getUsers())) {
            userList.add(userBean.toVo());
        }
        // 在线状态
        for (long uid : roomInfo.getUsers()) {
            allMessage.getOfflineStatus().put(uid, RedisManager.getUserRedisService().getGateId(uid) != null);
        }
        GameInfo gameInfo = (GameInfo) roomInfo.getGame();
        roomInfo.getReady(userId);
        if (gameInfo != null) {
            ReconnectResp reconnect = new ReconnectResp(gameInfo, userId);
            allMessage.setGameId(gameInfo.getGameId());
            allMessage.setCardNumber(gameInfo.getRemainCards().size());
            allMessage.setReconnectResp(reconnect);
        }
        allMessage.setUsers(userList);
        if (roomInfo.getTimerNode() != null) {
            long time = roomInfo.getTimerNode().getStart() + roomInfo.getTimerNode().getInterval() - System.currentTimeMillis();
            allMessage.setRemainTime(time);
        }
    }
    ResponseVo vo = new ResponseVo("reconnService", "reconnection", allMessage);
    MsgSender.sendMsg2Player(vo, userId);
    return 0;
}
Also used : AllMessage(com.code.server.game.mahjong.response.AllMessage) GameInfo(com.code.server.game.mahjong.logic.GameInfo) UserVo(com.code.server.constant.response.UserVo) UserBean(com.code.server.constant.game.UserBean) ArrayList(java.util.ArrayList) ReconnectResp(com.code.server.game.mahjong.response.ReconnectResp) RoomInfo(com.code.server.game.mahjong.logic.RoomInfo) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

UserVo (com.code.server.constant.response.UserVo)3 ResponseVo (com.code.server.constant.response.ResponseVo)2 UserBean (com.code.server.constant.game.UserBean)1 GameInfo (com.code.server.game.mahjong.logic.GameInfo)1 RoomInfo (com.code.server.game.mahjong.logic.RoomInfo)1 AllMessage (com.code.server.game.mahjong.response.AllMessage)1 ReconnectResp (com.code.server.game.mahjong.response.ReconnectResp)1 ArrayList (java.util.ArrayList)1