Class PacketTypeDiscovery
- Namespace
- BSGameLib.Networking
- Assembly
- BSGameLib.Networking.dll
Every packet type a game can receive: each IDataPacket in the given assemblies and in the assemblies its handled packets come from, and each packet a handler names.
public static class PacketTypeDiscovery
- Inheritance
-
PacketTypeDiscovery
- Inherited Members
Remarks
Discovered rather than listed. Registration is what lets a packet be received: a packet travels as the hash of its type name, and turning a hash back into a type needs the type to be known. Sending needs nothing, because the serializer is reflective and a type that is not registered gets its hash computed on the spot. So a packet with no handler yet still belongs here -- then giving it one later needs no registration change -- and a hand-kept list of the send-only packets, which a game used to carry, did nothing at all.
Two packet types with the same short name would share a hash, and the second would silently take the first one's place, so that is refused here, at startup, naming both.
Methods
Among(IEnumerable<Type>, IEnumerable<Type>)
The same, from packet types already found: candidates and the handled ones.
public static IReadOnlyList<Type> Among(IEnumerable<Type> candidates, IEnumerable<Type> handledPacketTypes)
Parameters
candidatesIEnumerable<Type>handledPacketTypesIEnumerable<Type>
Returns
Discover(IEnumerable<Assembly>, IEnumerable<Type>)
Returns every packet type in assemblies, in the assemblies that
handledPacketTypes come from, and the handled types themselves.
public static IReadOnlyList<Type> Discover(IEnumerable<Assembly> assemblies, IEnumerable<Type> handledPacketTypes)
Parameters
assembliesIEnumerable<Assembly>handledPacketTypesIEnumerable<Type>
Returns
Exceptions
- InvalidOperationException
Two packet types share a name.