/** * stdSuccess: 通用的处理成功方法。适用处理完成后不需要返回任何数据。只需要告知对端执行成功时调用! * * @param request 参数包,直接传入即可。 * @return RemotePacket */ protected RemotePacket stdSuccess(RemotePacket request) { RemotePacket packet = new RemotePacket(request.getMessageId() + 1, request.getUsername()); packet.put("result", 1); // 处理成功 return packet; }
// 以下为根据请求包创建一个标准的返回空包,然后继续填充数据 protected RemotePacket createResultPacket(RemotePacket request) { return new RemotePacket(request.getMessageId() + 1, request.getUsername()); }
/** * stdError: 通用的错误方法。适用于处理过程中出错返回! * * @param errorMsg 错误消息 * @return RemotePacket */ protected RemotePacket stdError(String errorMsg) { RemotePacket packet = new RemotePacket(RemoteCode.SBRemoteError, "SystemError"); packet.put("error", errorMsg); return packet; }