Beispiel #1
0
        /// <summary>
        /// Initializes connection with the server by creating tcp connection and Client channel with contract IGamePlayService
        /// </summary>
        public void InitializeServerConnection()
        {
            var             builder          = new ContainerBuilder();
            NetTcpBinding   binding          = new NetTcpBinding();
            EndpointAddress endpointGameplay = new EndpointAddress("net.tcp://" + ipAddress + ":8733/GamePlayService/");

            binding.Security.Mode  = SecurityMode.None;
            binding.OpenTimeout    = new TimeSpan(0, 0, 3);
            binding.CloseTimeout   = new TimeSpan(0, 0, 1);
            binding.SendTimeout    = new TimeSpan(0, 0, 1);
            binding.ReceiveTimeout = new TimeSpan(0, 0, 1);
            builder.Register(c => new InstanceContext(new CallbackHandler()));
            builder.Register(c => new DuplexChannelFactory <IGamePlayService>(c.Resolve <InstanceContext>(), binding, endpointGameplay)).AsSelf();
            builder.Register(c => new ClientChannel <IGamePlayService>(c.Resolve <DuplexChannelFactory <IGamePlayService> >().CreateChannel()));
            ClientServiceLocator.Setup(builder.Build(), true);
        }