public int handleMessage(ISession aSession, IRequestMessage aReqMsg, IResponsePackage aResPkg) { // mLog.debug("[BET] : Catch ; " + aSession.getUserName()); MessageFactory msgFactory = aSession.getMessageFactory(); DeleteMessageResponse resBet = (DeleteMessageResponse) msgFactory.getResponseMessage(aReqMsg.getID()); try { DeleteMessageRequest rqAddComment = (DeleteMessageRequest) aReqMsg; MessageDB db = new MessageDB(); db.deleteMessage(rqAddComment.type, rqAddComment.messageId, aSession.getUID()); resBet.mCode = ResponseCode.SUCCESS; aSession.write(resBet); CacheUserInfo cache = new CacheUserInfo(); cache.deleteCacheMessage(aSession.getUID()); } catch (Throwable t) { // resBet.setFailure(ResponseCode.FAILURE, t.getMessage()); mLog.error("Process message " + aReqMsg.getID() + " error.", t); try { resBet.setFailure(ResponseCode.FAILURE, "Co loi xay ra"); aSession.write(resBet); } catch (ServerException ex) { // java.util.logging.Logger.getLogger(TurnBusiness.class.getName()).log(Level.SEVERE, // null, ex); } } return 1; }
public int handleMessage(ISession aSession, IRequestMessage aReqMsg, IResponsePackage aResPkg) { mLog.debug("get TopGame"); MessageFactory msgFactory = aSession.getMessageFactory(); GetTopGameResponse resalbum = (GetTopGameResponse) msgFactory.getResponseMessage(aReqMsg.getID()); try { GetTopGameRequest rqAlb = (GetTopGameRequest) aReqMsg; UserEntity entity = aSession.getUserEntity(); CacheGameInfo cacheGame = new CacheGameInfo(); List<UserEntity> lstUsers = cacheGame.getTopGame(entity.partnerId, rqAlb.gameId); StringBuilder sb = new StringBuilder(); int userSize = lstUsers.size(); for (int i = 0; i < userSize; i++) { UserEntity usrEntity = lstUsers.get(i); sb.append(usrEntity.mUid).append(AIOConstants.SEPERATOR_BYTE_1); sb.append(usrEntity.mUsername).append(AIOConstants.SEPERATOR_BYTE_1); sb.append(usrEntity.point).append(AIOConstants.SEPERATOR_BYTE_1); sb.append(usrEntity.playsNumber).append(AIOConstants.SEPERATOR_BYTE_2); } if (userSize > 0) { sb.deleteCharAt(sb.length() - 1); } resalbum.setSuccess(sb.toString()); aResPkg.addMessage(resalbum); } catch (Exception ex) { mLog.error(ex.getMessage(), ex); resalbum.setFailure("co loi xay ra"); aResPkg.addMessage(resalbum); } // catch(BusinessException ex) // { // mLog.warn(ex.getMessage()); // resalbum.setFailure(ex.getMessage()); // // } finally { // if (resalbum!= null) // { // try { // aSession.write(resalbum); // } catch (ServerException ex) { // mLog.error(ex.getMessage(), ex); // } // // } } return 1; }
@Override public int handleMessage(ISession aSession, IRequestMessage aReqMsg, IResponsePackage aResPkg) { mLog.debug("[GET_AVATARS]: Catch"); MessageFactory msgFactory = aSession.getMessageFactory(); GetChooseAvatarResponse resBuyAvatar = (GetChooseAvatarResponse) msgFactory.getResponseMessage(aReqMsg.getID()); resBuyAvatar.session = aSession; try { GetChooseAvatarRequest rqBuyAvatar = (GetChooseAvatarRequest) aReqMsg; long uid = rqBuyAvatar.uid; String res = AvatarManager.getChooseAvatarForUser(uid, aSession.isMobileDevice()); resBuyAvatar.setSuccess(res); } catch (Throwable t) { t.printStackTrace(); resBuyAvatar.setFailure("Có lỗi xảy ra với avatar bạn muốn mua."); } finally { if ((resBuyAvatar != null)) { aResPkg.addMessage(resBuyAvatar); } } return 1; }