/// <summary>
        /// Returns the <see cref="SendReceiveOptions"/> to be used for the provided <see cref="PacketHeader"/>. Ensures there
        /// will not be a serializer or data processor clash for different delegate levels.
        /// </summary>
        /// <param name="header">The <see cref="PacketHeader"/> options are desired.</param>
        /// <returns>The requested <see cref="SendReceiveOptions"/></returns>
        internal SendReceiveOptions IncomingPacketSendReceiveOptions(PacketHeader header)
        {
            //Are there connection specific or global packet handlers?
            bool connectionSpecificHandlers = false;

            lock (_syncRoot) connectionSpecificHandlers = incomingPacketHandlers.ContainsKey(header.PacketType);

            bool globalHandlers = NetworkComms.GlobalIncomingPacketHandlerExists(header.PacketType);

            //Get connection specific options for this packet type, if there aren't any use the connection default options
            SendReceiveOptions connectionSpecificOptions = PacketTypeUnwrapperOptions(header.PacketType);

            if (connectionSpecificOptions == null)
            {
                connectionSpecificOptions = ConnectionDefaultSendReceiveOptions;
            }

            //Get global options for this packet type, if there aren't any use the global default options
            SendReceiveOptions globalOptions = NetworkComms.GlobalPacketTypeUnwrapperOptions(header.PacketType);

            if (globalOptions == null)
            {
                globalOptions = NetworkComms.DefaultSendReceiveOptions;
            }

            if (connectionSpecificHandlers && globalHandlers)
            {
                if (!connectionSpecificOptions.OptionsCompatible(globalOptions))
                {
                    throw new PacketHandlerException("Attempted to determine correct sendReceiveOptions for packet of type '" + header.PacketType + "'. Unable to continue as connection specific and global sendReceiveOptions are not equal.");
                }

                //We need to combine options in this case using the connection specific option in preference if both are present
                var combinedOptions = new Dictionary <string, string>(globalOptions.Options);

                foreach (var pair in connectionSpecificOptions.Options)
                {
                    combinedOptions[pair.Key] = pair.Value;
                }

                //If the header specifies a serializer and data processors we will auto detect those
                if (header.ContainsOption(PacketHeaderLongItems.SerializerProcessors))
                {
                    DataSerializer       serializer;
                    List <DataProcessor> dataProcessors;

                    DPSManager.GetSerializerDataProcessorsFromIdentifier(header.GetOption(PacketHeaderLongItems.SerializerProcessors), out serializer, out dataProcessors);
                    return(new SendReceiveOptions(serializer, dataProcessors, combinedOptions));
                }

                //Otherwise we will use options that were specified
                return(new SendReceiveOptions(connectionSpecificOptions.DataSerializer, connectionSpecificOptions.DataProcessors, combinedOptions));
            }
            //////////////////////////////////////////////
            //// Changed 20/05/14 to fix bug when encryption options is set on the listener and not the packet handler
            //////////////////////////////////////////////
            else //if (connectionSpecificHandlers)
            {
                //If the header specifies a serializer and data processors we will auto detect those
                if (header.ContainsOption(PacketHeaderLongItems.SerializerProcessors))
                {
                    DataSerializer       serializer;
                    List <DataProcessor> dataProcessors;

                    DPSManager.GetSerializerDataProcessorsFromIdentifier(header.GetOption(PacketHeaderLongItems.SerializerProcessors), out serializer, out dataProcessors);
                    return(new SendReceiveOptions(serializer, dataProcessors, connectionSpecificOptions.Options));
                }

                return(connectionSpecificOptions);
            }
            //else
            //{
            //    //If the header specifies a serializer and data processors we will auto detect those
            //    if (header.ContainsOption(PacketHeaderLongItems.SerializerProcessors))
            //    {
            //        DataSerializer serializer;
            //        List<DataProcessor> dataProcessors;

            //        DPSManager.GetSerializerDataProcessorsFromIdentifier(header.GetOption(PacketHeaderLongItems.SerializerProcessors), out serializer, out dataProcessors);
            //        return new SendReceiveOptions(serializer, dataProcessors, globalOptions.Options);
            //    }

            //    //If just globalHandlers is set (or indeed no handlers at all we just return the global options
            //    return globalOptions;
            //}
        }