Exemple #1
0
        private void FlushInternal()
        {
            if (_disconnecting.IsSet || _connectionError.IsSet)
            {
                return;
            }

            if (_connectionsCounter.Wait(TimeSpan.FromMilliseconds(1d)))
            {
                try
                {
                    _canFetch.WaitOne();

                    body body = CombineBody();

                    _canFetch.Set();

                    var resp = SendRequest(body);

                    ExtractBody(resp);
                }
                finally
                {
                    _connectionsCounter.Release();

                    if (!_tagQueue.IsEmpty)
                    {
                        Task.Run(() => Flush());
                    }
                }
            }
        }
Exemple #2
0
        private void SendSessionCreationRequest()
        {
            var body = new body
            {
                rid  = _rid,
                wait = Wait,
                hold = Hold,
                from = _manager.Settings.Id.Bare,
                to   = _manager.Settings.Id.Server
            };

            var resp = SendRequest(body);

            if (null != resp)
            {
                IsConnected = true;

                _manager.Events.Connected(this);

                _sid      = resp.sid;
                _requests = resp.requests;

                _connectionsCounter = new SemaphoreSlim(_requests.Value, _requests.Value);

                var payload = resp.Element <tags.streams.features>(tags.streams.Namespace.features);

                _manager.State = new ServerFeaturesState(_manager);
                _manager.State.Execute(payload);
            }
        }
Exemple #3
0
    public void Die(bool body)
    {
        if (!photonView.IsMine)
        {
            return;
        }

        desactiveButton();

        //active animation and disable the collider for the player
        isDead = true;
        myController.isDead = true;
        mycollider.enabled  = false;

        myAvatarSprite.gameObject.layer = 12;
        playerNameText.gameObject.layer = 12;

        lumbraFov.obstacleMask = LayerMask.GetMask("Nothing");

        realCamera.cullingMask = realCamera.cullingMask ^ (1 << 12);

        if (body)
        {
            body tempBody = PhotonNetwork.Instantiate("body", transform.position, transform.rotation).GetComponent <body>();
            tempBody.gm           = GameManager;
            tempBody.reportButton = reportButton;
            //set the color of the body according to the player current color;
            tempBody.setColor(myAvatarSprite.color);
        }
    }
Exemple #4
0
 public animal(int no_leg_joints, int no_body_joints) : base()
 {
     hind_leg = new leg(no_leg_joints);
     torso    = new body(no_body_joints);
     skull    = new head();
     subject  = hind_leg;        // the default view is of the leg (this should be changed for the final draft)
 }
Exemple #5
0
 public Packet_0A(int period, int duty, byte num)
 {
     Command = 0x0A;
     b       = new body {
         period = (UInt16)period, duty = (UInt16)duty, feature_number = num
     };
     BodySize = getSize(b);
 }
Exemple #6
0
 public Packet_06(int start, int stop, int delay)
 {
     Command = 6;
     b       = new body {
         start = (UInt16)start, stop = (UInt16)stop, delay = (UInt16)delay
     };
     BodySize = getSize(b);
 }
Exemple #7
0
 await PostRequestAsync <TRequest, TResponse, TResponse>(
     hostname,
     relativeUri,
     request,
     cancellationToken,
     body,
     parameters,
     headers);
Exemple #8
0
 public Packet_02(byte num, bool enabled)
 {
     Command   = 2;
     BodySize  = 2;
     b         = new body();
     b.num     = num;
     b.enabled = getByte(enabled);
 }
Exemple #9
0
 private void ExtractBody(body resp)
 {
     if (null != resp)
     {
         foreach (var element in resp.Elements <XElement>())
         {
             _manager.Events.NewTag(this, Tag.Get(element));
         }
     }
 }
Exemple #10
0
        private body SendRequest(body body)
        {
            using (var req = new HttpRequestMessage
            {
                RequestUri = new Uri(_manager.Settings.Hostname),
                Method = new HttpMethod("POST"),
                Content = new HttpStringContent(body, UnicodeEncoding.Utf8),
            })
            {
                req.Content.Headers.ContentType = new HttpMediaTypeHeaderValue("text/xml")
                {
                    CharSet = "utf-8",
                };

                try
                {
                    using (var resp = _client.SendRequestAsync(req).AsTask().Result)
                    {
                        if (resp.IsSuccessStatusCode)
                        {
                            var data = resp.Content.ReadAsStringAsync().AsTask().Result;

                            Interlocked.Exchange(ref _retryCounter, 0);

                            return(Tag.Get(data) as body);
                        }

                        ConnectionError(
                            ErrorType.ConnectToServerFailed,
                            ErrorPolicyType.Reconnect,
                            string.Format(
                                "Connection error: Status: {0} Reason Phrase: {1}",
                                resp.StatusCode,
                                resp.ReasonPhrase),
                            body);
                    }
                }
                catch (AggregateException e)
                {
                    if (!(e.InnerException is TaskCanceledException))
                    {
                        ConnectionError(
                            ErrorType.ConnectToServerFailed,
                            ErrorPolicyType.Reconnect,
                            e.Message,
                            body);
                    }
                }

                return(null);
            }
        }
Exemple #11
0
        private void SendSessionTerminationRequest()
        {
            var body = new body
            {
                sid  = _sid,
                rid  = Interlocked.Increment(ref _rid),
                type = "terminate"
            };

            CombineBody(body);

            SendRequest(body);
        }
Exemple #12
0
        private body CombineBody()
        {
            var body = new body
            {
                sid  = _sid,
                rid  = Interlocked.Increment(ref _rid),
                from = _manager.Settings.Id,
                to   = _manager.Settings.Id.Server
            };

            CombineBody(body);

            return(body);
        }
Exemple #13
0
        internal static void VisualizeModelNode(this IModelNode?modelNode)
        {
            _ = modelNode ?? throw new ArgumentNullException(nameof(modelNode));
            var xml       = UserDifferencesHelper.GetUserDifferences(modelNode)[""];
            var prettyXml = new XmlFormatter().Format(xml);
            var encode    = WebUtility.HtmlEncode(prettyXml);
            var html      = @$ "
<html>
    <head>
        <link href='https://unpkg.com/[email protected]/themes/prism-okaidia.css' rel='stylesheet' />
    </head>
    <body style='background-color: #272822; color: #bbb; font-family: sans-serif; margin: 0; padding: 0;'>
        <h1 style='text-align: center; margin-top: .5rem'>XAF Layout Inspector</h1>
        <hr style='border: none; border-top: 1px solid #bbb;' />
        <pre><code class='language-xml'>{encode}</code></pre>
Exemple #14
0
    /*
     *@brief : randomize the player params
     */
    public void randomPlayer()
    {
        int lenght = ethnie.GetNames(typeof(ethnie)).Length;
        int rand   = Random.Range(0, lenght);

        e = (ethnie)rand;

        lenght   = body.GetNames(typeof(body)).Length;
        rand     = Random.Range(0, lenght);
        b        = (body)rand;
        handicap = false;
        //handicap = intToBool(Random.Range(0, 2));
        gender      = intToBool(Random.Range(0, 2));
        sexuality   = intToBool(Random.Range(0, 2));
        scolarSkill = intToBool(Random.Range(0, 2));
    }
Exemple #15
0
        private void CombineBody(body body)
        {
            int counter = _manager.Settings.QueryCount;

            while (!_tagQueue.IsEmpty)
            {
                XElement tag;
                if (_tagQueue.TryDequeue(out tag))
                {
                    body.Add(tag);
                    if (--counter == 0)
                    {
                        break;
                    }
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// struct body to XML
        /// </summary>
        /// <param name="re">struct body</param>
        /// <param name="page">page</param>
        /// <param name="pagesize">pagesize</param>
        /// <returns>xml</returns>
        public static string bodyToXML(body re, int page, int pagesize)
        {
            XmlDocument xml = new XmlDocument();

            xml.LoadXml(re.dt.DataSet.GetXml());
            XmlElement p = xml.CreateElement("Page");

            p.InnerXml = page.ToString();
            xml.FirstChild.AppendChild((XmlNode)p);
            XmlElement ps = xml.CreateElement("PageSize");

            ps.InnerXml = pagesize.ToString();
            xml.FirstChild.AppendChild((XmlNode)ps);
            XmlElement c = xml.CreateElement("Count");

            c.InnerXml = re.count.ToString();
            xml.FirstChild.AppendChild((XmlNode)c);
            return(xml.DocumentElement.OuterXml);
        }
Exemple #17
0
        private void button2_Click(object sender, EventArgs e)
        {
            moving      = Directions.right;
            label2.Text = "0";
            snake       = new List <body>();
            body temp = new body();

            temp.x = 100;
            temp.y = 100;
            snake.Add(temp);
            food   = new body();
            food.x = thing.Next(panel1.Width) / 10 * 10;
            food.y = thing.Next(panel1.Height) / 10 * 10;
            UpdateGraphics();
            panel1.Invalidate();
            timer1.Start();
            button1.Hide();
            button2.Hide();
        }
Exemple #18
0
        private void SendRestartRequest()
        {
            var body = new body
            {
                sid     = _sid,
                rid     = Interlocked.Increment(ref _rid),
                restart = true,
                to      = _manager.Settings.Id.Server
            };

            var resp = SendRequest(body);

            if (null != resp)
            {
                var payload = resp.Element <tags.streams.features>(tags.streams.Namespace.features);

                _manager.State = new ServerFeaturesState(_manager);
                _manager.State.Execute(payload);
            }
        }
Exemple #19
0
        /// <summary>
        /// Writes out a 404 error page with 404 error status
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private async Task Status404Page(HttpContext context, string additionalHtml = null, bool isFallback = false)
        {
            if (string.IsNullOrEmpty(additionalHtml) && isFallback)
            {
                additionalHtml = @"
<p>A fallback URL is configured but was not found: <b>{ServerConfig.FolderNotFoundFallbackPath}</b></p>

<p>The fallback URL can be used for SPA application to handle server side redirection to the initial
client side startup URL - typically <code>/index.html</code>. This URL is loaded if
a URL cannot otherwise be handled. This error page is displayed because the specified fallback
page or resource also does not exist.</p>
";
            }

            if (!context.Response.HasStarted)
            {
                context.Response.StatusCode  = 404;
                context.Response.ContentType = "text/html";
            }

            await context.Response.WriteAsync(@$ "
<html>
<body style='font-family: sans-serif; margin:2em 5%; max-width: 978px;'>
Exemple #20
0
 public bool Same(body obj)
 {
     return(x == obj.x && y == obj.y);
 }
Exemple #21
0
 public Packet_04(TimersConfiguration timersConfiguration)
 {
     Command  = 4;
     b        = Utils.Create <body>(timersConfiguration);
     BodySize = getSize(b);
 }
Exemple #22
0
        private static void Main(string[] args)
        {
            LogException newlog = new LogException();

            newlog.write_log();

            Console.WriteLine("Данные о танке:");
            body status1 = new body();

            status1.bodyOutput();
            track status2 = new track();

            status2.trackOutput();
            tower status3 = new tower();

            status3.towerOutput();
            engine status4 = new engine();

            status4.engineOutput();
            transmission status5 = new transmission();

            status5.transmissionOutput();
            weaponary status6 = new weaponary();

            status6.weaponaryOutput();
            communication status7 = new communication();

            status7.communicationOutput();
            surveillance status8 = new surveillance();

            status8.surveillanceOutput();
            Weapons status9 = new Weapons();

            status9.crewOutput();
            status9.weaponsNumber();

            aboutTank   ui           = new aboutTank();
            Read_config _Read_config = new Read_config();

            _Read_config.read_file();

            ui.crewNum = 5;
            Console.WriteLine("Экипаж");
            Console.WriteLine(ui.crewNum);
            Console.WriteLine("Название танка");
            Console.WriteLine(ui.Name);

            // ____________________________________________________________________Serialization XML JSON Binary
            try
            {
                interface_ISerializer ISerialize = new interface_ISerializer();
                ISerialize.Serialize();
                ISerialize.Deserialize();
            }
            catch (Exception)
            {
                Console.WriteLine("Не сработала сериализация");
                Console.ReadLine();
            }
            // ____________________________________________________________________Serialization XML JSON Binary


            Console.ReadLine();
        }
Exemple #23
0
 select SerializeObject(body, SerializerSettings);
 { createPullRequest, new CreatePullRequestModel(repositoryId, baseRefName, headRefName, title, body, clientMutationId, maintainerCanModify, draft) }
Exemple #25
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (GetAsyncKeyState(38) != 0 && moving != Directions.down)
            {
                moving = Directions.up;
            }
            else if (GetAsyncKeyState(37) != 0 && moving != Directions.right)
            {
                moving = Directions.left;
            }
            else if (GetAsyncKeyState(39) != 0 && moving != Directions.left)
            {
                moving = Directions.right;
            }
            else if (GetAsyncKeyState(40) != 0 && moving != Directions.up)
            {
                moving = Directions.down;
            }

            body temp = snake[0];

            if (moving == Directions.up)
            {
                temp.y -= 10;
            }
            else if (moving == Directions.down)
            {
                temp.y += 10;
            }
            else if (moving == Directions.left)
            {
                temp.x -= 10;
            }
            else if (moving == Directions.right)
            {
                temp.x += 10;
            }
            if (temp.x >= panel1.Width || temp.x < 0 || temp.y >= panel1.Height || temp.y < 0 || snake.Contains(temp))
            {
                timer1.Stop();
                MessageBox.Show("Game over!");
                CheckHighScore();
                button2.Show();
                button1.Show();
            }
            snake.Insert(0, temp);
            if (!food.Same(temp))
            {
                Rectangle tailRefresh = new Rectangle(snake[snake.Count - 1].x, snake[snake.Count - 1].y, 10, 10);
                snake.RemoveAt(snake.Count - 1);
                Rectangle headRefresh = new Rectangle(snake[0].x, snake[0].y, 10, 10);
                UpdateGraphics();
                panel1.Invalidate(tailRefresh);
                panel1.Invalidate(headRefresh);
            }
            else
            {
                label2.Text = Convert.ToString(Convert.ToInt32(label2.Text) + 1);
                food.x      = thing.Next(panel1.Width) / 10 * 10;
                food.y      = thing.Next(panel1.Height) / 10 * 10;
                Rectangle foodRefresh = new Rectangle(food.x, food.y, 10, 10);
                Rectangle headRefresh = new Rectangle(snake[0].x, snake[0].y, 10, 10);
                UpdateGraphics();
                panel1.Invalidate(foodRefresh);
                panel1.Invalidate(headRefresh);
            }

            //UpdateGraphics();
            //panel1.Invalidate();
        }
Exemple #26
0
        private void ConnectionError(ErrorType type, ErrorPolicyType policy, string cause, body body)
        {
            if (_disconnecting.IsSet)
            {
                return;
            }

            if (string.IsNullOrEmpty(body.sid) || Interlocked.Increment(ref _retryCounter) >= MaxRetry)
            {
                if (!_connectionError.IsSet)
                {
                    _connectionError.Set();

                    _manager.Events.Error(this, type, policy, cause);
                }
            }
            else
            {
                foreach (var item in body.Elements())
                {
                    _tagQueue.Enqueue(item);
                }
            }
        }