Toemsel / Network

C# Network Library
https://push-force.dev
GNU Lesser General Public License v3.0
355 stars 65 forks source link

KeyNotFound while using RawData #54

Closed Toemsel closed 4 years ago

Toemsel commented 4 years ago
  1. Create a TcpConnection
  2. Register a raw packet handler
  3. InvokePacketThreadException gets raised.

Between point 1. and 2. the server may already send a packet with the rawData key provided within step two. However, the client doesn't have that key yet. Due to the Dict impl. following exception will be risen:

{System.Collections.Generic.KeyNotFoundException: The given key 'LoginServerRequestHandshake1' was not present in the dictionary. at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in /Dictionary.cs:226 at Network.Utilities.PacketHandlerMap.get_Item (System.String key) [0x00000] in PacketHandlerMap.cs:46 at Network.Connection.HandleDefaultPackets (Network.Packets.Packet packet) [0x003c0] in k\Connection.cs:851 at Network.Connection.InvokeWork () [0x00033] in \Connection.cs:669 }

Code

Expected behaviour:

Toemsel commented 4 years ago

Fixed https://github.com/Toemsel/Network/pull/57