Browse Source

Merge branch 'master' of https://github.com/SoftwareGuy/ENet-CSharp

Matt Coburn 6 years ago
parent
commit
a79827a1ee
1 changed files with 14 additions and 0 deletions
  1. 14 0
      COMMON-MISTAKES.md

+ 14 - 0
COMMON-MISTAKES.md

@@ -0,0 +1,14 @@
+**Originally from a pinned nxrighthere repo issue:**
+
+Since newcomers make the same mistakes over and over again, and people are reading the API reference not careful enough, I will collect all common mistakes here.
+1. **Packet.Dispose() called right after sending a packet.** Never dispose a packet after enqueuing it for sending, ENet does that for you automatically, otherwise, a memory access failure will occur.
+
+2. **Packet.Dispose() called more than once per received packet.** The Packet structure is a value type thus internal checks will fail for two different copies of a packet, and a memory access failure will occur. Try to keep processing flow under strict control. If the received packet will be sent further, you should not dispose it since ENet will use it as you normally enqueuing a packet for sending.
+
+3. **Channels limit didn't match at the endpoints.** Always make sure that the channel limit set to the same value at the endpoints using Host.Create() and Host.Connect() functions, otherwise, packets will not be delivered on disabled channels.
+
+4. **Round-trip time is unstable even on localhost.** This is the first indication that the Host.Service() is not called often enough. Make sure that the service and events are processed continuously and nothing prevents the ENet to shuttle packets across peers.
+
+5. **Latency gets higher relatively to a count of concurrent connections.** Make sure that only the actual payload is sent and not a whole buffer, a packet should be created with the correct length using the Packet.Create() function. Check that the ENet is not overwhelmed with large reliably fragmented packets.
+
+6. **The host is not flushed after the service is no longer in a loop.** Always flush the host before the end of a session to ensure that all queued packets and protocol commands were sent to its designated peers.