Beispiel #1
0
        public async void ConnectToClient(string hostName, int port, string playerName,  Color color)
        {
            var binding = new WSDualHttpBinding(WSDualHttpSecurityMode.None);
            binding.ReceiveTimeout = TimeSpan.FromSeconds(30);
            binding.SendTimeout = TimeSpan.FromSeconds(30);

            //TODO: Wire up the callbackHandler...

            _client = new GameServiceClient(
                new InstanceContext(_callbackHandler), 
                binding,
                new EndpointAddress(String.Format("http://{0}:{1}/GameService", hostName, port)));
            _client.Open();

            //Just calling join here locks up...
            PlayerId = await _client.JoinAsync(new Player
            {
                Name = playerName,
                Color = new Service.Contracts.Color 
                {
                    A = color.A,
                    R = color.R,
                    G = color.G,
                    B = color.B
                }
            });

            //TODO: Remove this once the view goes somewhere else...
            MessageBox.Show(String.Format("Player: {0} joined with id: {1}", playerName, PlayerId));
        }