FreecraftCore is an open-source C#/.NET World of Warcraft emulation project. It is derived from the reverse engineering work done by Mangos and Trinitycore.
The FreecraftCore.Payload.Serializer is a metadata based serializer for WoW packets based on JAM and inspired by the design of Protobuf-net by Marc.
The Serializer reflects on Types for attributes (looks at metadata) marked on wire message types to build a simple serializer that reads and writes from a stream. The primitive datatype reading and writing is based on Trinitycore's ByteBuffer. All serialization is just a decoration of the primitive datatype serialization strategies.
In short, FreecraftCore.Serializer knows how to serialize primitives in the fashion that the WoW protocol excepts and all serialization functionality is an extension of this via decoration.
To understand how this serializer works read documentation related to Protobuf-Net here. The design is similar.
[WireDataContract] //mark wire messages with this attribute
public class MyMessagePayload
{
[WireMember(1)] //Mark members you want sent over the network with [WireMember] attributes. A unique per class int key is required.
public int Damage;
[WireMember(5)] //the keys don't need to go in sequence. No benefit really.
public string TargetName;
[WireMember(7)]
public MyCustomType Instance; //you can send custom types over the network too.
//Arrays, Enums and even some basic Polymorphism works!
public MyMessagePayload() //as of right now the serializer requires a parameterless ctor. This will be changed in the future
{
}
}
public class MyCustomType //non wiremessages don't need to be marked but if you want to use polymorphic serialization you should mark
{
[WireMember(1)]
public int data;
public MyMessagePayload() //non wire messages still require a parameterless ctor (for now)
{
}
}
[KnownSize(5)]
[WireMember(1)]
SomeType[][] //Multidimensional arrays are partially supported but not fixed sized ones.
[WireMember(1)]
IEnumerable<SomeType> //Any collection except arrays are currently unsupported but planned for future support
Available on a Nuget Feed: https://www.myget.org/F/freecraftcore/api/v2
Linux Debug | Windows .NET Debug | |
---|---|---|
master | TODO | |
dev | TODO |
(Done locally)
This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE so follow it or I will report you to the software gods.