LastExceed
01/21/2020, 12:09 PMPacket
(for networking) that needs a serialize
and deserialize
function. the former is easy, just a regular abstract function with a ByteWriteChannel
param to write the packet into. the latter however needs to be either a top-level extension function for ByteReadChannel
or in the companion object, neither of which allows the abstract
keyword (obviously). how do I ensure that each Packet
class implements a deserialize
factory function ?Nikky
01/21/2020, 11:24 PMdeserialize
to call?
i would opt for a exhaustive when
with some enum or making Packets a sealed class
that way i should not overlook or miss anyNikky
01/21/2020, 11:27 PMByteReadChannel
, assuming your packets are not in a serialization supported format