Example #1
0
        private static async Task <PixelResponse> SendPixel(PixelRequest pixel)
        {
            string apiHost       = "https://BitPixel.chainstack.nz";
            string apiPublicKey  = "1a4cfeed5aea423c942142e88d8f5033";
            string apiPrivateKey = "8thxiu2FuuFoRnfgDCL+R1EH/ZZ8V0eoPCPp8AYIndQ=";

            pixel.ApiKey    = apiPublicKey;
            pixel.Signature = CreateSignature(apiPrivateKey, pixel.GetRequestBody());

            using (var client = new HttpClient())
            {
                var response = await client.PostAsJsonAsync($"{apiHost}/Api/AddPixel", pixel);

                return(JsonConvert.DeserializeObject <PixelResponse>(await response.Content.ReadAsStringAsync()));
            }
        }
Example #2
0
    public void AddNewRequest(MagicRequest magicRequest)
    {
        PixelRequest pixelRequest = new PixelRequest();

        pixelRequest.name = magicRequest.type.ToString();
        pixelRequest.pixelCountRequested = magicRequest.pixelValue;
        pixelRequest.endTime             = Time.time + timePerRequest;

        switch (magicRequest.direction)
        {
        case MagicRequest.Direction.Right:
            rightRequests.Add(pixelRequest);
            onNewRequest.Invoke(pixelRequest);
            break;

        case MagicRequest.Direction.Left:
            leftRequests.Add(pixelRequest);
            onNewRequest.Invoke(pixelRequest);
            break;

        case MagicRequest.Direction.Both:
            //Add a little bit of time if its around
            pixelRequest.endTime = Time.time + timePerRequest * 1.5f;

            leftRequests.Add(pixelRequest);
            PixelRequest pixelRequest2 = new PixelRequest();
            pixelRequest2.name = pixelRequest.name;
            pixelRequest2.pixelCountRequested = pixelRequest.pixelCountRequested;
            pixelRequest2.endTime             = pixelRequest.endTime;
            rightRequests.Add(pixelRequest2);

            onNewRequest.Invoke(pixelRequest);
            onNewRequest.Invoke(pixelRequest2);

            break;
        }
    }