BlowaXD / ChickenAPI

OpenSource Nostale Private Server Emulator API, implemented by SaltyEmu
https://blowaxd.github.io/ChickenAPI/
GNU General Public License v3.0
41 stars 7 forks source link

[REVIEW] Facilitate & optimise packet serialization / deserialization #98

Closed BlowaXD closed 5 years ago

BlowaXD commented 5 years ago

Review Packet over network (serialization)

This pull request will solve #97

Description

Packet serialization is a big part of nostale projects, a lot of packets are still waiting to be correctly handled and defined on OpenNos, which is a long time living project.

Actual behavior

Actually, packets are serialized inside a big class that is "doing the job" with attributes on properties, class and

A lot of packets have their own way to be serialized, even though, this can be done through attributes without difficulties, however, having a single class with a lot of special behaviors that needs to be implemented is difficult to maintain and also it can decrease performances.

SaltyEmu packet Serialization NosCore packet serialization OpenNos packet serialization

Expected behavior

I'd like to implement a serializer/deserializer for each packet, which does not relate itself on meta attributes to serialize the data correctly. However, those attributes could still be used as informations for maintainers.

I think something like this could help all emulators to be interoperable as long as they implement a proper serialization.

Any suggests are welcomed.

erwan-joly commented 5 years ago

My suggestion would be to use a DefaultPacketDeserializer and an interface instead of a abstract class.

BlowaXD commented 5 years ago

I agree for the deserialization part which can help saving a lot of time for devs. But we should keep 1 serializer per packet. (At least, as far as we can, otherwise we can have a fallback on the actuals PacketFactories..)