Forum Feedback Suggestion Latency Test

Problem with the website? Confused about something? Or maybe you just have something you'd like to suggest. This is the place to do it.

Suggestion Latency Test

Postby SteelBattle » February 6th, 2011, 9:14 pm

Hello,

I would like to try my interpolation and extrapolation works fine but it is impossible in the developpement serveur because of the 3/4 ms ping in the loopback interface.

Maybe developers should appreciate a configuration on the server witch force the "waiting" of an ammount of seconds before responding to any query from any client.

PS : I will try with a dirty "for(int i = 0; i < 1000000; i++)", it will works but, not verry clean :D !

Cordially
SteelBattle
 
Posts: 7
Joined: December 8th, 2010, 2:01 pm

Re: Suggestion Latency Test

Postby Oliver » February 7th, 2011, 4:29 pm

So, you want a "Fake lag" option in the development server?

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Suggestion Latency Test

Postby SteelBattle » February 7th, 2011, 4:36 pm

Yes, exactly !

Or the possibility to use Thread.Sleep() available in System.Threading.

Cordially.
SteelBattle
 
Posts: 7
Joined: December 8th, 2010, 2:01 pm

Re: Suggestion Latency Test

Postby tzachs » February 9th, 2011, 2:13 pm

I'd second both suggestions, having a "fake lag" option would be great, I'm having the exact same issue of everything working perfect on the development server, and not so perfect on the real server.
Also putting the Thread.Sleep in the white list will be useful.

As for the "fake lag" option, it would be nice if it was smart enough to simulate different scenarios (one fast client and one slow client, for instance), and also randomizing the lag, so it will be closer to how it really works (I think)...
tzachs
 
Posts: 8
Joined: January 19th, 2011, 10:33 pm

Re: Suggestion Latency Test

Postby HAnz » February 15th, 2011, 7:17 pm

I would also quite like this feature. :)
I make games and stuff.
User avatar
HAnz
 
Posts: 46
Joined: August 7th, 2010, 2:59 pm

Re: Suggestion Latency Test

Postby GBurg » February 17th, 2011, 1:18 pm

Defenitely want this option (however, with a random function and a timer you can simulate it yourself off course ;))
GBurg
Paid Member
 
Posts: 78
Joined: February 9th, 2011, 10:27 am

Re: Suggestion Latency Test

Postby tzachs » February 17th, 2011, 10:01 pm

If anyone's interested, I wrote a wrapper for simulating random lags.

Here's the class:
Code: Select all
using System;
using System.Collections.Generic;
using PlayerIO.GameLibrary;

namespace ServersideGameCode
{
    public class ServerWrapper
    {
        private Queue<WrapperMessage> messages;
        private Random random;
        private Game<Player> game;
        private int lagCounter = 0;

        private const int chanceForLag = 100;
        private const int maxLag = 20;

        public ServerWrapper(Game<Player> game, Random random)
        {
            this.game = game;
            this.random = random;
            messages = new Queue<WrapperMessage>();
        }

        public void Update()
        {
            if (isLag()) return;
            update();
        }

        public void Send(Player player, Message message)
        {
            if (game.InDevelopmentServer)
            {
                if (isLag())
                {
                    messages.Enqueue(new WrapperMessage(player, message));
                }
                else
                {
                    update();
                    send(player, message);
                }
            }
            else
            {
                send(player, message);
            }
        }

        public void Send(Player player, string type, params object[] parameters)
        {
            Message message = Message.Create(type, parameters);
            Send(player, message);
        }

        public void Broadcast(Message message)
        {
            Send(null, message);
        }

        public void Broadcast(string type, params object[] parameters)
        {
            Send(null, type, parameters);
        }

        private bool isLag()
        {
            if (lagCounter > 0)
            {
                lagCounter--;
                if (lagCounter == 0) return false;
                return true;
            }
            if (random.Next(chanceForLag) == 0)
            {
                lagCounter = random.Next(maxLag);
                return true;
            }
            return false;
        }

        private void send(Player player, Message message)
        {
            if (player == null)
            {
                game.Broadcast(message);
            }
            else
            {
                player.Send(message);
            }
        }

        private void update()
        {
            while (messages.Count > 0)
            {
                WrapperMessage message = messages.Dequeue();
                send(message.Player, message.Message);
            }
        }
       
        private class WrapperMessage
        {
            public WrapperMessage(Player player,
                Message message)
            {
                Message = message;
                Player = player;
            }

            public Message Message { get; private set; }
            public Player Player { get; private set; }
        }
    }
}


Usage:
* Replace your Broadcast & Player.Send calls with the appropriate calls of the wrapper.
* Call the Update method from your main timer that updates the data.
* Change the consts chanceForLag & maxLag, for different lags scenarios.
The larger chanceForLag is, the smaller is the chance for a lag.
The larger maxLag is, the bigger the chance for a larger lag.
* You don't have to worry about deployment, it will only simulate lags if you're on the development server. Otherwise, it will send the message normally.
tzachs
 
Posts: 8
Joined: January 19th, 2011, 10:33 pm

Re: Suggestion Latency Test

Postby SteelBattle » February 18th, 2011, 11:22 am

Thanks for the participation, i will try your trick :)
SteelBattle
 
Posts: 7
Joined: December 8th, 2010, 2:01 pm

Re: Suggestion Latency Test

Postby Oliver » February 18th, 2011, 3:41 pm

If anyone's interested, I wrote a wrapper for simulating random lags.


O_o ... Swweeeeeettt!
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to Feedback



cron