Comments (4)
Thanks again and you can close the issue.
CharacterListModel:
@Getter
@Builder
@EzyArrayBinding
public class CharacterListModel {
Long id;
Long accountId;
String name;
String sex;
String race;
String model;
}
CharacterController:
@EzyDoHandle(Commands.CHARACTER_LIST)
public void characterList(EzyUser user)
{
logger.info("user {} request character list", user.getName());
responseFactory.newArrayResponse()
.command(Commands.CHARACTER_LIST)
.data(
convert(characterService.getAllCharacters(user))
)
.user(user)
.execute();
}
private CharacterListModel[] convert(List<Character> characters)
{
CharacterListModel[] chars = new CharacterListModel[characters.size()];
int i=0;
for (Character character : characters) {
CharacterListModel characterListModel = CharacterListModel.builder()
.id(character.getId())
.accountId(character.getAccountId())
.name(character.getName())
.sex(character.getSex())
.race(character.getRace())
.model(character.getModel())
.build();
chars[i] = characterListModel;
i++;
}
return chars;
}
from ezyfox-server.
You need to add @EzyArrayBinding
to Character
, you can take a look docs here: https://youngmonkeys.org/ezyfox-library/guides/ezyfox-binding-marshal-unmarshal
from ezyfox-server.
i've added
@Data
@EzyCollection
@EzyArrayBinding
public class Character {
@EzyId
Long id;
Long accountId;
String name;
String sex;
String race;
String model;
}
but now i get some error without sending response if i only try to read the List from the database with:
List<Character> chars = characterService.getAllCharacters(user);
public List<Character> getAllCharacters(EzyUser user) {
Account account = accountRepo.findByField("username", user.getName());
return characterRepo.findListByField("accountId", account.getId());
}
Error: Caused by: com.tvd12.ezyfox.binding.exception.EzyReadValueException: can't read value: {accountId=2, race=Humanoid, sex=female, name=Assambra, model=äsldkfälskdfälskdj, _id=1} to: com.assambra.game.common.entity.Character
Error: Caused by: java.lang.ClassCastException: com.tvd12.ezyfox.entity.EzyHashMap cannot be cast to com.tvd12.ezyfox.entity.EzyArray
from ezyfox-server.
Hmm, because you're using this class for the both mongodb entity and response, you should not do that, you need to remove @EzyArrayBinding from the class, create a new response class and convert from entity to response
from ezyfox-server.
Related Issues (20)
- Feature: send via udp or tcp
- Can not receive UDP request when a client has TCP IP and UDP IP are not same
- The Rooms per socket HOT 1
- Plugin 'org.apache.maven.plugins:maven-antrun-plugin:3.0.0' not found HOT 3
- Use gzip to zip request response HOT 3
- Demo link is not found HOT 5
- Support Docker Build HOT 4
- Add getExecutorService method to EzyZoneChildContext
- It is not possible to run two zones on one server with correct behaviour HOT 10
- The client no longer receives position data for a short period of time HOT 37
- [all]add debug mode to server
- [statistics]measure dropped pakets, dropped bytes
- build-issue: niocodec missing dependency HOT 3
- Lỗi không add packages to scan
- typo error com.tvd12.ezyfoxserver.controller.EzyAccessAppController
- Board cast for AppUserAdded
- Didn't call init method in setting builder
- Allows client send encryption algorithm in handshake request
- Unify code style
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ezyfox-server.