Esempio n. 1
0
 public CGamePlay()
 {
     client0 = null;
     client1 = null;
     questions = new List<Question>();
     CreateQuestions(@"..\..\resources\question.txt");
     ShuffleQuestions();
     qi = 0;
     callbacklist = new List<IGameplayCallback>();
 }
Esempio n. 2
0
 /// <summary>
 /// Method runs when a client disconnect, callback & client reset
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Channel_Faulted(object sender, EventArgs e)
 {
     try
     {
         callbacklist[0].LeaveNotify();
         callbacklist.RemoveAt(1);
         client1 = null;
         client0.Reset();
     }
     catch
     {
         try
         {
             callbacklist[1].LeaveNotify();
             callbacklist.RemoveAt(0);
             client0 = null;
             client1.Reset();
         }
         catch
         {
             callbacklist.Clear();
             client0 = null;
             client1 = null;
         }
     }
     qi = 0;
 }
Esempio n. 3
0
 /// <summary>
 /// Creates the clients and creates the callback
 /// </summary>
 /// <param name="clientname">name of the new client</param>
 /// <param name="succes">is true if clientcreation is succes</param>
 /// <returns></returns>
 public bool Connect(string clientname, out bool succes)
 {
     succes = false;
     bool returnvalue = false;
     IGameplayCallback callback = OperationContext.Current.GetCallbackChannel<IGameplayCallback>();
     if (client0 == null)
     {
         if (client1 != null)
             if (client1.name == clientname)
             {
                 clientname = clientname + "-1";
                 returnvalue = true;
             }
         client0 = new Client(clientname);
         callbacklist.Insert(0, callback);
         OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted);
         OperationContext.Current.Channel.Closed += new EventHandler(Channel_Faulted);
         succes = true;
     }
     else if (client1 == null)
     {
         if (client0.name == clientname)
         {
             clientname = clientname + "-1";
             returnvalue = true;
         }
         client1 = new Client(clientname);
         callbacklist.Insert(1, callback);
         OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted);
         OperationContext.Current.Channel.Closed += new EventHandler(Channel_Faulted);
         succes = true;
     }
     return returnvalue;
 }