Beispiel #1
0
        public static void HandleRequest(NetIncomingMessage message)
        {
            int channel    = message.SequenceChannel;
            int subChannel = message.ReadRangedInteger(0, TOTAL_CHANNELS);
            int key        = channel * CHANNEL_SIZE + subChannel;

            Hooks.TryGetValue(key, out List <Tuple <Action <NetIncomingMessage, object>, bool> > hooks);
            if (hooks != null)
            {
                message.SkipPadBits();
                int numberOfBytes = message.ReadInt32();
                message.SkipPadBits();

                byte[] data = message.ReadBytes(numberOfBytes);

                object obj = ObjectSerialization.ByteArrayToObject(data);
                for (int i = 0; i < hooks.Count; i++)
                {
                    hooks[i]?.Item1?.Invoke(message, ObjectSerialization.ByteArrayToObject(data));
                }
            }
            else
            {
                Console.WriteLine("Channel not handeled: {0}, {1}", channel, subChannel);
            }
        }