/// <inheritdoc />
        public override void Register(ContainerBuilder register)
        {
            EncryptionLazyWithoutKeyDecorator <byte[]> encrypt = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishEncryptionService encryptionService = new BlowfishEncryptionService();
                encryptionService.Initialize(val);
                return(encryptionService);
            }, 8);
            EncryptionLazyWithoutKeyDecorator <byte[]> decrypt = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishDecryptionService decryptionService = new BlowfishDecryptionService();
                decryptionService.Initialize(val);
                return(decryptionService);
            }, 8);

            IManagedNetworkClient <PSOBBGamePacketPayloadClient, PSOBBGamePacketPayloadServer> client = new DotNetTcpClientNetworkClient()
                                                                                                        .AddCryptHandling(encrypt, decrypt)
                                                                                                        .AddBufferredWrite(4)
                                                                                                        .AddHeaderReading <PSOBBPacketHeader>(Serializer.Value, 2)
                                                                                                        .AddNetworkMessageReading(Serializer.Value)
                                                                                                        .For <PSOBBGamePacketPayloadServer, PSOBBGamePacketPayloadClient, IPacketPayload>(new PSOBBPacketHeaderFactory())
                                                                                                        .AddReadBufferClearing()
                                                                                                        .Build()
                                                                                                        .AsManaged(new UnityLoggingService(LoggingLevel));

            register.RegisterInstance(client)
            .As <IManagedNetworkClient <PSOBBGamePacketPayloadClient, PSOBBGamePacketPayloadServer> >()
            .As <IPeerPayloadSendService <PSOBBGamePacketPayloadClient> >()
            .As <IPayloadInterceptable>();

            register.RegisterType <DefaultMessageContextFactory>()
            .As <IPeerMessageContextFactory>()
            .SingleInstance();

            register.RegisterType <PayloadInterceptMessageSendService <PSOBBGamePacketPayloadClient> >()
            .As <IPeerRequestSendService <PSOBBGamePacketPayloadClient> >()
            .SingleInstance();

            register.RegisterInstance(new SeperateAggregateCryptoInitializationService <byte[]>(encrypt, decrypt))
            .As <IFullCryptoInitializationService <byte[]> >()
            .SingleInstance();

            //TODO: This is all so hacky, is this really what we're going to do forever??
            register.RegisterType <GlobalExportableClient>()
            .As <INetworkClientExportable>()
            .SingleInstance();

            register.RegisterType <DefaultConnectionRedirector>()
            .As <IConnectionRedirector>();

            register.RegisterType <GlobalConnectionService>()
            .As <IConnectionService>()
            .SingleInstance();

            //TODO: This is a hack to help prevent mobile network issues
            this.gameObject.AddComponent <DisconnectClientOnNonExportableSceneChange>();
        }
        /// <inheritdoc />
        protected override ContainerBuilder RegisterHandlerDependencies(ContainerBuilder builder)
        {
            //Client crypto
            //We create the shared block cipher service here.
            ClientEncryptionService = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishEncryptionService encryptionService = new BlowfishEncryptionService();
                encryptionService.Initialize(val.ToArray());
                return(encryptionService);
            }, 8);

            ClientDecryptionService = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishDecryptionService decryptionService = new BlowfishDecryptionService();
                decryptionService.Initialize(val.ToArray());
                return(decryptionService);
            }, 8);

            //Server crypto
            ServerEncryptionService = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishEncryptionService encryptionService = new BlowfishEncryptionService();
                encryptionService.Initialize(val.ToArray());
                return(encryptionService);
            }, 8);

            ServerDecryptionService = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishDecryptionService decryptionService = new BlowfishDecryptionService();
                decryptionService.Initialize(val.ToArray());                 //for PROXY PURPOSES ONLY we have to copy so we don't modify the key used by the other end
                return(decryptionService);
            }, 8);

            //Register all the crypto providers as crypto initializers
            RegisterCryptoInitializable(builder, ClientEncryptionService, CryptoType.Decryption);
            RegisterCryptoInitializable(builder, ClientDecryptionService, CryptoType.Encryption);
            RegisterCryptoInitializable(builder, ServerEncryptionService, CryptoType.Encryption);
            RegisterCryptoInitializable(builder, ServerDecryptionService, CryptoType.Decryption);


            builder
            .Register <IFullCryptoInitializationService <byte[]> >(context =>
            {
                return(new ProxiedFullCryptoInitializable(new AggergateCryptoInitializer(context.ResolveKeyed <IEnumerable <ICryptoKeyInitializable <byte[]> > >(CryptoType.Encryption)), new AggergateCryptoInitializer(context.ResolveKeyed <IEnumerable <ICryptoKeyInitializable <byte[]> > >(CryptoType.Decryption))));
            });

            builder.RegisterInstance(new BinaryPacketWriter("Packets"))
            .AsSelf()
            .SingleInstance()
            .ExternallyOwned();

            return(builder);
        }
        /// <inheritdoc />
        public override void Register(ContainerBuilder register)
        {
            EncryptionLazyWithoutKeyDecorator <byte[]> encrypt = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishEncryptionService encryptionService = new BlowfishEncryptionService();
                encryptionService.Initialize(val);
                return(encryptionService);
            }, 8);
            EncryptionLazyWithoutKeyDecorator <byte[]> decrypt = new EncryptionLazyWithoutKeyDecorator <byte[]>(val =>
            {
                BlowfishDecryptionService decryptionService = new BlowfishDecryptionService();
                decryptionService.Initialize(val);
                return(decryptionService);
            }, 8);

            IManagedNetworkClient <PSOBBGamePacketPayloadClient, PSOBBGamePacketPayloadServer> client = new DotNetTcpClientNetworkClient()
                                                                                                        .AddCryptHandling(encrypt, decrypt)
                                                                                                        .AddBufferredWrite(4)
                                                                                                        .AddHeaderReading <PSOBBPacketHeader>(Serializer.Value, 2)
                                                                                                        .AddNetworkMessageReading(Serializer.Value)
                                                                                                        .For <PSOBBGamePacketPayloadServer, PSOBBGamePacketPayloadClient, IPacketPayload>(new PSOBBPacketHeaderFactory())
                                                                                                        .AddReadBufferClearing()
                                                                                                        .Build()
                                                                                                        .AsManaged(new UnityLoggingService(LoggingLevel));

            register.RegisterInstance(client)
            .As <IManagedNetworkClient <PSOBBGamePacketPayloadClient, PSOBBGamePacketPayloadServer> >()
            .As <IPeerPayloadSendService <PSOBBGamePacketPayloadClient> >()
            .As <IPayloadInterceptable>()
            .As <IConnectionService>();

            register.RegisterType <DefaultMessageContextFactory>()
            .As <IPeerMessageContextFactory>()
            .SingleInstance();

            register.RegisterType <PayloadInterceptMessageSendService <PSOBBGamePacketPayloadClient> >()
            .As <IPeerRequestSendService <PSOBBGamePacketPayloadClient> >()
            .SingleInstance();

            register.RegisterInstance(new SeperateAggregateCryptoInitializationService <byte[]>(encrypt, decrypt))
            .As <IFullCryptoInitializationService <byte[]> >()
            .SingleInstance();
        }