Example #1
0
 private void FindGame()
 {
     using (var channelFactory = new ChannelFactory <IBattleshipsService>("MyNetNamedPipeEndpoint"))
     {
         IBattleshipsService client = channelFactory.CreateChannel();
         Game foundGame             = client.FindGame(me);
         MainMenuUc.Visibility = Visibility.Hidden;
         GameUc.StartGame(foundGame.GameId, me.PlayerId);
     }
 }
Example #2
0
        private void JoinGame()
        {
            int gameId;

            if (!int.TryParse(Interaction.InputBox("Join Game", "Set game id number value"), out gameId))
            {
                MessageBox.Show("Game id must be a number...");
                return;
            }
            using (var channelFactory = new ChannelFactory <IBattleshipsService>("MyNetNamedPipeEndpoint"))
            {
                IBattleshipsService client = channelFactory.CreateChannel();
                Game foundGame             = client.JoinGame(me, gameId);
                if (foundGame == null)
                {
                    MessageBox.Show($"Game with id {gameId} not found");
                    return;
                }
                MainMenuUc.Visibility = Visibility.Hidden;
                GameUc.StartGame(foundGame.GameId, me.PlayerId);
            }
        }