Ejemplo n.º 1
0
 public MainWindow()
 {
     cl = (ClientBody)WPFclient.App.Current.Properties["client"];
     //https://stackoverflow.com/questions/15657637/condition-variables-c-net //read on CV
     InitializeComponent();
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
 }
Ejemplo n.º 2
0
        public inRoom(bool _isAdmin, int _questionsNum, int _time, int _playersNum, string _roomName)
        {
            windows = WPFclient.App.Current.Windows; //for waitForMsg
            isAdmin = _isAdmin;
            cl      = (ClientBody)WPFclient.App.Current.Properties["client"];
            InitializeComponent();
            questionNum.Content = questionNum.Content.ToString() + _questionsNum;
            time.Content        = time.Content.ToString() + _time;
            players.Content     = players.Content.ToString() + _playersNum;
            room.Content        = room.Content.ToString() + _roomName;
            UserName.Content    = cl._username;

            ListBoxItem user = new ListBoxItem();

            user.Content = cl._username;
            usersList.Items.Add(user);
            if (!isAdmin)
            {//hide the start game and close game buttons, as they aren't allowed for a non admin, and show the leave game button, and instructions
                //instead of the number of players, that is intended only for admins.
                players.Content             = "Please wait for the admin to start the game";
                adminExitButton.Visibility  = Visibility.Collapsed;
                adminStartButton.Visibility = Visibility.Collapsed;
                joinerExit.Visibility       = Visibility.Visible;
            }
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            background_worker.WorkerSupportsCancellation = true;
            background_worker.WorkerReportsProgress      = true;
            background_worker.DoWork          += background_worker_DoWork;
            background_worker.ProgressChanged += background_worker_ProgressChanged;

            background_worker.RunWorkerAsync(this);
        }
Ejemplo n.º 3
0
 ClientBody cl; //shared class
 public createRoom()
 {
     cl = (ClientBody)WPFclient.App.Current.Properties["client"];
     InitializeComponent();
     UserName.Content      = cl._username;
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
 }
Ejemplo n.º 4
0
 ClientBody cl; //shared class
 public gameResults(int questionNum)
 {
     qNum = questionNum;
     cl   = (ClientBody)WPFclient.App.Current.Properties["client"];
     InitializeComponent();
     this.Closed += new EventHandler(theWindow_Closed);
     getResults();
 }
Ejemplo n.º 5
0
 string room = ""; //for the joinRoom button to know which room is selected
 public joinRoom()
 {
     cl = (ClientBody)WPFclient.App.Current.Properties["client"];
     InitializeComponent();
     UserName.Content = cl._username;
     getRooms(); //initial room list request
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
 }
Ejemplo n.º 6
0
 public mainMenu()
 {
     cl = (ClientBody)WPFclient.App.Current.Properties["client"];
     cl._clientStream.Flush(); // when somthing is interrupted by pressing the menu button, flush the stream so it can be used
     InitializeComponent();
     if ((bool)WPFclient.App.Current.Properties["isAdmin"])
     {
         addQuestions.Visibility = Visibility.Visible;
     }
     UserName.Content      = cl._username;
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
 }
Ejemplo n.º 7
0
        public game(int _timePerQ, int _questionNum)
        {
            cl = (ClientBody)WPFclient.App.Current.Properties["client"];
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.Background       = new ImageBrush(new BitmapImage(new Uri(@"pack://application:,,,/WPFclient;component/BG.png")));

            timePerQuestion  = _timePerQ;
            questionNum      = _questionNum;
            currQuestion     = 0; corrects = 0;
            UserName.Content = cl._username;
            rcvQuestion();
        }
Ejemplo n.º 8
0
        ClientBody cl; //shared class
        public connectedUser(string id)
        {
            cl = (ClientBody)WPFclient.App.Current.Properties["client"];
            InitializeComponent();
            UserName.Content = cl._username;
            //send the users in room request to server
            byte[] buffer = new ASCIIEncoding().GetBytes("207" + id);
            byte[] rcv    = new byte[3];
            cl._clientStream.Write(buffer, 0, buffer.Length);
            cl._clientStream.Flush();
            cl._clientStream.Read(rcv, 0, 3);
            string answer = System.Text.Encoding.UTF8.GetString(rcv);

            if (answer != "108") /*failure*/ MessageBox {
Ejemplo n.º 9
0
        /// <summary>
        /// Request password reset **Note:** this endpoint is available in Alfresco 5.2.1 and newer versions.  Initiates the reset password workflow to send an email with reset password instruction to the user&#39;s registered email.  The client is mandatory in the request body. For example: &#x60;&#x60;&#x60;JSON {   \&quot;client\&quot;: \&quot;myClient\&quot; } &#x60;&#x60;&#x60; **Note:** The client must be registered before this API can send an email. See [server documentation]. However, out-of-the-box share is registered as a default client, so you could pass **share** as the client name: &#x60;&#x60;&#x60;JSON {   \&quot;client\&quot;: \&quot;share\&quot; } &#x60;&#x60;&#x60; **Note:** No authentication is required to call this endpoint.
        /// </summary>
        /// <param name="personId">The identifier of a person.</param>
        /// <param name="clientBody">The client name to send email with app-specific url.</param>
        /// <returns></returns>
        public void RequestPasswordReset(string personId, ClientBody clientBody)
        {
            // verify the required parameter 'personId' is set
            if (personId == null)
            {
                throw new ApiException(400, "Missing required parameter 'personId' when calling RequestPasswordReset");
            }

            // verify the required parameter 'clientBody' is set
            if (clientBody == null)
            {
                throw new ApiException(400, "Missing required parameter 'clientBody' when calling RequestPasswordReset");
            }


            var path = "/people/{personId}/request-password-reset";

            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "personId" + "}", ApiClient.ParameterToString(personId));

            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;

            postBody = ApiClient.Serialize(clientBody);                                     // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] { "basicAuth" };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling RequestPasswordReset: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling RequestPasswordReset: " + response.ErrorMessage, response.ErrorMessage);
            }

            return;
        }
Ejemplo n.º 10
0
 public ClientReturn Post(ClientRequest CR, ClientBody CB)
 {
     return(POST.Invoke(instance, new object[] { CR, CB }) as ClientReturn);
 }
Ejemplo n.º 11
0
 public ClientReturn Post(ClientRequest CR, ClientBody CB)
 {
     return(this.GetSite(CR).Post(CR, CB));
 }
Ejemplo n.º 12
0
        private Response GenerateResponse(ClientRequest CR)
        {
            if (CR.Host == null)
            {
                Response BR = new Response(Response.Code.N400, new TextResource("Sabertooth requires that clients have Host fields in their headers."));
                BR.connectionStatus = Instruction.Connection.Close;
                return(BR);
            }
            if (!(CR.Type == "GET" || CR.Type == "POST" || CR.Type == "HEAD"))
            {
                Response BR = new Response(Response.Code.N400, new TextResource("Sabertooth only supports GET, POST, and HEAD at the moment."));
                return(BR);
            }
            string realm;
            Tuple <string, string> auth = CR.Authorization;

            if (!Gen.IsAuthorized(CR, auth, out realm))
            {
                Response AUTH = new Response(Response.Code.N401);
                AUTH.AddInstruction(Instruction.Authenticate(realm));
                return(AUTH);
            }
            CacheData CD = Gen.GetCacheData(CR);

            if ((CR.LastModified != new DateTime() && CR.LastModified == CD.LastModified) || (CR.LastModified == new DateTime() && CD.ETag != String.Empty && CR.ETag == CD.ETag))
            {
                Response NM = new Response(Response.Code.N304);
                NM.MaxAge = CD.MaxAge;
                return(NM);
            }
            Response Res;

            try {
                ClientBody   CB = CR.ReadBody();
                ClientReturn GenRes;
                if (CB == null)
                {
                    GenRes = Gen.Get(CR);
                }
                else
                {
                    GenRes = Gen.Post(CR, CB);
                }
                if (GenRes == null)
                {
                    throw new ArgumentNullException("The mandate failed to generate a page, hopefully an error log appears above.");
                }
                if (GenRes.Redirect == null)
                {
                    Res = new Response(Response.Code.N200);
                }
                else
                {
                    Res = new Response(Response.Code.N307);
                    Res.AddInstruction(new Instruction("Location", GenRes.Redirect));
                }
                foreach (SetCookie S in GenRes.SetCookies)
                {
                    Res.AddInstruction(Instruction.SetCookie(S));
                }
                if (CD.LastModified != new DateTime())
                {
                    Res.AddInstruction(Instruction.LastModified(CD.LastModified));
                }
                if (CD.ETag != String.Empty)
                {
                    Res.AddInstruction(Instruction.ETag(CD.ETag));
                }
                Res.SetBody(GenRes.Body);
                Res.MaxAge = GenRes.MaxAge;
            } catch (Exception e) {
                Console.WriteLine(e);
                Response ISE = new Response(Response.Code.N500, new TextResource("If you are reading this text, the Sabertooth mandate responsible for this request has encountered an error: \n" + e));
                ISE.connectionStatus = Instruction.Connection.Close;
                return(ISE);
            }
            return(Res);
        }
Ejemplo n.º 13
0
 ClientBody cl; //shared class
 public signUp()
 {
     cl = (ClientBody)WPFclient.App.Current.Properties["client"];
     InitializeComponent();
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
 }