Beispiel #1
0
    ///<summary>
    /// Create an DELETE request from _input.
    ///</summary>
    ///<param name="_obj">The OgreeObject to delete</param>
    public void CreateDeleteRequest(OgreeObject _obj)
    {
        SRequest request = new SRequest();

        request.type = "delete";
        request.path = $"/{_obj.category}s/{_obj.id}";
        requestsToSend.Enqueue(request);
    }
        public override Task <SResponse> SendStatus(SRequest request, ServerCallContext context)
        {
            List <StatusInfo> statusList = StatusRepo();
            SResponse         sRes       = new SResponse();

            sRes.StatusInfo.AddRange(statusList.Skip(request.No - 1).Take(1));
            return(Task.FromResult(sRes));
        }
Beispiel #3
0
    ///<summary>
    /// Create an PUT request from _input.
    ///</summary>
    ///<param name="_obj">The OgreeObject to put</param>
    public void CreatePutRequest(OgreeObject _obj)
    {
        SRequest request = new SRequest();

        request.type = "put";

        SApiObject apiObj = new SApiObject(_obj);

        request.path = $"/{apiObj.category}s/{apiObj.id}";
        request.json = JsonConvert.SerializeObject(apiObj);
        requestsToSend.Enqueue(request);
    }
Beispiel #4
0
        public override async Task SendStatusSS(SRequest request, IServerStreamWriter <SResponse> responseStream, ServerCallContext context)
        {
            List <StatusInfo> statusList = StatusRepo();
            SResponse         sRes;
            var i = 0;

            while (!context.CancellationToken.IsCancellationRequested)
            {
                sRes = new SResponse();
                sRes.StatusInfo.Add(statusList.Skip(i).Take(request.No));
                await responseStream.WriteAsync(sRes);

                i++;
                await Task.Delay(1000);
            }
        }
Beispiel #5
0
 private void processMessage(PmlElement Message)
 {
     if (Message is PmlString)
     {
         String cmd = Message.ToString();
         if (cmd == "PING")
         {
             _WriteMessage("PONG");
         }
         else if (cmd == "PONG")
         {
         }
     }
     else if (Message is PmlDictionary)
     {
         String cmd = Message.GetChild("CMD").ToString();
         if (cmd == "SES")
         {
             processSessionMessage(Message);
         }
         else if (cmd == "RPL")
         {
             UInt32       SID = Message.GetChild("SID").ToUInt32();
             CSyncRequest SRequest;
             lock (_invocations) {
                 if (!_invocations.TryGetValue(SID, out SRequest))
                 {
                     SRequest = null;
                 }
                 _invocations.Remove(SID);
             }
             if (SRequest != null)
             {
                 SRequest.Completed((PmlDictionary)Message);
             }
         }
         else if (cmd == "REQ" || cmd == "MSG")
         {
             UThreadPool.RunCall(processCall, Message);
         }
     }
 }
Beispiel #6
0
    ///<summary>
    /// Send a delete request to the api.
    ///</summary>
    private async void DeleteHttpData()
    {
        isReady = false;

        SRequest req      = requestsToSend.Dequeue();
        string   fullPath = server + req.path;

        try
        {
            HttpResponseMessage response = await httpClient.DeleteAsync(fullPath);

            string responseStr = response.Content.ReadAsStringAsync().Result;
            GameManager.gm.AppendLogLine(responseStr, false);
        }
        catch (HttpRequestException e)
        {
            GameManager.gm.AppendLogLine(e.Message, false, eLogtype.error);
        }

        isReady = true;
    }
Beispiel #7
0
    ///<summary>
    /// Send a put request to the api.
    ///</summary>
    private async void PutHttpData()
    {
        isReady = false;

        SRequest      req      = requestsToSend.Dequeue();
        string        fullPath = server + req.path;
        StringContent content  = new StringContent(req.json, System.Text.Encoding.UTF8, "application/json");

        try
        {
            HttpResponseMessage response = await httpClient.PutAsync(fullPath, content);

            string responseStr = response.Content.ReadAsStringAsync().Result;
            GameManager.gm.AppendLogLine(responseStr, false);
        }
        catch (HttpRequestException e)
        {
            GameManager.gm.AppendLogLine(e.Message, false, eLogtype.error);
        }

        isReady = true;
    }