Search in sources :

Example 46 with ResponseVo

use of com.code.server.constant.response.ResponseVo 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 47 with ResponseVo

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

the class GameUserService method getNickNamePlayer.

/**
 * 获取昵称
 *
 * @param msgKey
 * @return
 */
public int getNickNamePlayer(KafkaMsgKey msgKey) {
    UserBean userBean = userRedisService.getUserBean(msgKey.getUserId());
    if (userBean == null) {
        return ErrorCode.YOU_HAVE_NOT_LOGIN;
    }
    Map<String, Object> results = new HashMap<String, Object>();
    try {
        results.put("nickname", userBean.getUsername());
    } catch (Exception e) {
        ResponseVo vo = new ResponseVo("userService", "getNickNamePlayer", ErrorCode.NOT_HAVE_THIS_ACCEPTER);
        sendMsg(msgKey, vo);
    }
    ResponseVo vo = new ResponseVo("userService", "getNickNamePlayer", results);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 48 with ResponseVo

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

the class GameUserService method getPrepareRoom.

public int getPrepareRoom(KafkaMsgKey msgKey) {
    long userId = msgKey.getUserId();
    Map<String, PrepareRoom> rooms = RedisManager.getUserRedisService().getPerpareRoom(userId);
    Map<Object, Object> result = new HashMap<>();
    List<Map<String, Object>> list = new ArrayList<>();
    if (rooms != null) {
        for (Map.Entry<String, PrepareRoom> entry : rooms.entrySet()) {
            Map<String, Object> temp = new HashMap<>();
            temp.put("room", entry.getValue());
            temp.put("user", RedisManager.getUserRedisService().getUserBeans(RedisManager.getRoomRedisService().getUsers(entry.getKey())));
            list.add(temp);
        }
    }
    result.put("result", list);
    ResponseVo vo = new ResponseVo("userService", "getPrepareRoom", result);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 49 with ResponseVo

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

the class GameUserService method getCoords.

/**
 * 获得同一房间的所有人坐标
 *
 * @param msgKey
 * @return
 */
public int getCoords(KafkaMsgKey msgKey) {
    long userId = msgKey.getUserId();
    String roomId = RedisManager.getUserRedisService().getRoomId(userId);
    if (roomId == null) {
        return ErrorCode.CAN_NOT_NO_ROOM;
    }
    Set<Long> users = RedisManager.getRoomRedisService().getUsers(roomId);
    Map<Long, Object> result = RedisManager.getUserRedisService().getUserBeans(users).stream().collect(Collectors.toMap(UserBean::getId, UserBean::getCoord));
    sendMsg(msgKey, new ResponseVo("userService", "getCoords", result));
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Example 50 with ResponseVo

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

the class GameUserService method setReplay.

public int setReplay(KafkaMsgKey msgKey, long id) {
    ReplayService rs = SpringUtil.getBean(ReplayService.class);
    // boolean isSuccess = rs.decReplayCount(id);
    // if (!isSuccess) {
    // return ErrorCode.REPLAY_NOT_EXIST;
    // }
    rs.decReplayCount(id);
    ResponseVo vo = new ResponseVo("userService", "setReplay", 0);
    sendMsg(msgKey, vo);
    return 0;
}
Also used : ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

ResponseVo (com.code.server.constant.response.ResponseVo)125 Club (com.code.server.db.model.Club)17 HashMap (java.util.HashMap)15 UserBean (com.code.server.constant.game.UserBean)8 IdWorker (com.code.server.util.IdWorker)8 ServerConfig (com.code.server.game.poker.config.ServerConfig)7 ArrayList (java.util.ArrayList)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ClubMember (com.code.server.constant.club.ClubMember)5 Charge (com.code.server.db.model.Charge)5 User (com.code.server.db.model.User)5 GameOfResult (com.code.server.constant.response.GameOfResult)4 UserOfResult (com.code.server.constant.response.UserOfResult)4 TimerNode (com.code.server.util.timer.TimerNode)4 RoomModel (com.code.server.constant.club.RoomModel)3 KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)3 com.code.server.game.mahjong.response (com.code.server.game.mahjong.response)3 MsgSender (com.code.server.game.room.kafka.MsgSender)3 MsgProducer (com.code.server.kafka.MsgProducer)3 Map (java.util.Map)3