markiodev / Networker

A simple to use TCP and UDP networking library for .NET. Compatible with Unity.
MIT License
477 stars 77 forks source link

Small code clean up #33

Closed erictuvesson closed 5 years ago

erictuvesson commented 5 years ago

Hey,

The only change I have done here is add this to the Server.

void Broadcast(byte[] packet)
markiodev commented 5 years ago

Thanks for your contribution!

If you send a byte[] to the clients and there is no data about which type of packet you are sending then the client will not be able to handle it. I should add some more information to the wiki about packet structure but it looks something like:

PacketTypeName_Size PacketData_Size PacketTypeName PacketData

If you are relaying the above packet it would work, otherwise it will be simply unhandled on the client end.

What are you trying to achieve with broadcasting a byte[]?

erictuvesson commented 5 years ago

I want to be able to skip the serializer and send just bytes.

Some packets I want to send are serialized in a more optimal.

I never ended up trying it out since I also want to do the same with the TCP socket and make it easier to send packets there.

erictuvesson commented 5 years ago

Note: While working on this I noticed that the ProtobufNet is not working

markiodev commented 5 years ago

I have an idea for sending the byte[] (and other data clr types) which I want to give a bit more thought to. The other changes all look good.

I'll look at why ProtobufNet is not working as I continue writing my tutorial.