Exemplo n.º 1
0
        private static void RevokeCertificate()
        {
            try
            {
                string           myName      = WindowsIdentity.GetCurrent().Name.Split('\\')[1];
                X509Certificate2 certificate = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, myName);
                if (certificate == null)
                {
                    return;
                }

                NetTcpBinding binding = new NetTcpBinding();
                InitializeWindowsAuthentication(binding);
                EndpointAddress address          = new EndpointAddress(new Uri(ConfigurationSettings.AppSettings.Get("CMSProxy")));
                var             callbackInstance = new ClientCallback();
                cmsClient.RevokeCertificate(certificate);
                Console.WriteLine("Certificate CN={0} successfully revoked!", myName);
            }
            catch (ArgumentNullException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SecurityException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public Dashboard(ServiceClient client, ClientCallback Callback, string username)
        {
            InitializeComponent();

            Client   = client;
            Username = username;
            callback = Callback;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ClientCallback clCallback = new ClientCallback();
            InstanceContext instCtx = new InstanceContext(clCallback);

            DuplexClient client = new DuplexClient(instCtx);
            client.Request(2000, 5);

            Console.ReadLine();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ClientCallback  clCallback = new ClientCallback();
            InstanceContext instCtx    = new InstanceContext(clCallback);

            DuplexClient client = new DuplexClient(instCtx);

            client.Request(2000, 5);

            Console.ReadLine();
        }
Exemplo n.º 5
0
 public Lobby(ServiceClient client, ClientCallback callback, string username)
 {
     online = true;
     try
     {
         InitializeComponent();
         InviteB.Visibility = Visibility.Hidden;
         timer    = new DispatcherTimer();
         Client   = client;
         Username = username;
         Callback = callback;
         Client   = client;
         callback.ReceivedInvitation = ShowReceivedInvitation; //assign to delegate
         client.AddPlayerToLobby(username);                    //add the player to the wating list
         mainWindow         = null;
         ConnIndicator.Fill = System.Windows.Media.Brushes.Green;
         FillLBOnLine();//FillLBOnLine get from the server all the online and available players
     }
     catch (FaultException <InvitationFault> fault)
     {
         MessageBox.Show(fault.Detail.Details, Username);
     }
     catch (TimeoutException)
     {
         timer.Stop();
         ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
         online             = false;
         MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", Username + " connection unstable");
         this.Close();
     }
     catch (CommunicationObjectFaultedException)
     {
         timer.Stop();
         ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
         online             = false;
         MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable");
         this.Close();
     }
     catch (Exception ex)
     {
         timer.Stop();
         ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
         online             = false;
         MessageBox.Show(ex.ToString(), Username + " connection unstable");
         this.Close();
     }
 }
        private ClientInstances()
        {
            var callback = new ClientCallback();

            ChatHost = new TalkBackService.ChatServiceClient(new System.ServiceModel.InstanceContext(callback));
            GameHost = new TalkBackService.GameServiceClient(new System.ServiceModel.InstanceContext(callback));

            PrivateChats  = new Dictionary <string, PrivateChat>();
            GameList      = new Dictionary <string, Backgammon>();
            HowFirstsList = new Dictionary <string, HowIsFirst>();
            Time          = new Time();
            TimeTimer     = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            TimeTimer.Tick += TimeTimer_Tick;
            TimeTimer.Start();
        }
Exemplo n.º 7
0
        private static CMSClient ConnectToCMS()
        {
            try
            {
                NetTcpBinding binding = new NetTcpBinding();
                InitializeWindowsAuthentication(binding);
                EndpointAddress address          = new EndpointAddress(new Uri(ConfigurationSettings.AppSettings.Get("CMSProxy")));
                var             callbackInstance = new ClientCallback();
                CMSClient       proxy            = new CMSClient(callbackInstance, binding, address);
                proxy.RegisterClient();

                return(proxy);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
Exemplo n.º 8
0
        /*back to dashboard*/
        private void BTDB_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Client.ClientDisconnect(Username);//remove player from wating list
                ClientCallback callback1 = new ClientCallback();
                ServiceClient  client1   = new ServiceClient(new InstanceContext(callback1));

                Dashboard mainWindow = new Dashboard(client1, callback1, Username);
                mainWindow.Title = Username;
                this.Close();
                mainWindow.Show();
            }
            catch (TimeoutException)
            {
                timer.Stop();
                ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
                online             = false;
                MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", Username + " connection unstable");
                this.Close();
            }
            catch (CommunicationObjectFaultedException)
            {
                timer.Stop();
                ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
                online             = false;
                MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable");
                this.Close();
            }
            catch (Exception ex)
            {
                timer.Stop();
                ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
                online             = false;
                MessageBox.Show(ex.ToString(), Username);
                this.Close();
            }
        }
Exemplo n.º 9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(tbUsername.Text) && !string.IsNullOrEmpty(tbPasswrd.Password))
            {
                ClientCallback callback = new ClientCallback();
                ServiceClient  client   = new ServiceClient(new InstanceContext(callback));
                c = client;


                string username = tbUsername.Text.Trim();
                string password = tbPasswrd.Password.Trim();
                try
                {
                    client.ClientConnected(username, HashValue(password));
                    Dashboard mainWindow = new Dashboard(client, callback, username);
                    mainWindow.Title = username;
                    this.Close();
                    mainWindow.Show();
                }
                catch (FaultException <WrongPasswordFault> fault)
                {
                    MessageBox.Show(fault.Detail.Details, username);
                }
                catch (TimeoutException)
                {
                    MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", username + " connection unstable");
                }
                catch (CommunicationObjectFaultedException)
                {
                    MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", username + " connection unstable");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), username);
                }
            }
        }
 public GameWindow(ServiceClient client, ClientCallback callback, string username, string gameId, bool myturn)
 {
     InitializeComponent();
     CloseGame = false;
     Client    = client;
     Callback  = callback;
     Username  = username;
     GameId    = gameId;
     /* assign to delegates */
     callback.AddMove     = AddCircle;
     callback.OnOffCan    = MyTurn;
     callback.EndLostGame = Lost;
     callback.EndDrawGame = Draw;
     callback.callbackEndGameOtherPlayerQuit = EndGameOtherPlayerQuit;
     /* CountMyMoves to know how many balls this player has in each column */
     CountMyMoves = new int[6];
     for (int i = 0; i < 6; i++)
     {
         CountMyMoves[i] = 0;
     }
     /* cols to know how many balls for the two players in each  column*/
     cols = new Dictionary <string, int>();
     cols.Add("c1", 0);
     cols.Add("c2", 0);
     cols.Add("c3", 0);
     cols.Add("c4", 0);
     cols.Add("c5", 0);
     cols.Add("c6", 0);
     /* colsCanvs to konw to which canvs to add a ball */
     colsCanvs = new Dictionary <string, Canvas>();
     colsCanvs.Add("c1", c1);
     colsCanvs.Add("c2", c2);
     colsCanvs.Add("c3", c3);
     colsCanvs.Add("c4", c4);
     colsCanvs.Add("c5", c5);
     colsCanvs.Add("c6", c6);
     /* int matrix of the game board , we add to to matrix only the moves of this player */
     GameBoard = new int[6, 7];
     for (int i = 0; i < 6; i++)
     {
         for (int j = 0; j < 7; j++)
         {
             GameBoard[i, j] = 0;
         }
     }
     MyTurn(myturn);                       //call the function MyTurn
     thr = new Thread(ServiceClientAlive); ///catch here not in the thread
     try
     {
         thr.Start();
     }
     catch (TimeoutException)
     {
         MessageBox.Show(" connection unstable , it took to long to get a response this game is canceled", Username + " connection unstable");
         thr.Abort();
         CloseGame = true;
         this.Close();
     }
     catch (CommunicationObjectFaultedException)
     {
         MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable");
         thr.Abort();
         CloseGame = true;
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), Username);
         thr.Abort();
         CloseGame = true;
         this.Close();
     }
 }