Table Of Contents

Previous topic

20.31. The NetworkLatencyBehavior Object

Next topic

20.33. The Observer Object

This Page

20.32. The NetworkLatencySimulator Object

Provides the ability to locally simulate network latency without the need for third party network weather simulators. This allows different clients running on the same host machine to be configured to have different latencies to test various scenarios, e.g. one large latency client connected other lower latency clients.

While this is a useful developer tool it should complement, and not replace, testing remotely on https://hub.turbulenz.com, and testing with multiple independent client machines.

Required scripts

/*{{ javascript("jslib/networklatencysimulator.js") }}*/

20.32.1. Constructor

20.32.1.1. create

Summary

Creates and returns a NetworkLatencySimulator object.

This modifies Utilities.ajax() to delay its messages.

Individual MultiPlayerSession objects can be added using ‘addMultiplayerSession’.

Syntax

var behavior = NetworkLatencyBehavior.create({latency : 50,
                                            delayPeriod : 1000,
                                            delayDuration : 100});

var simulator = NetworkLatencySimulator.create(behavior);
behavior
An object that implements the NetworkLatencyBehavior interface.

20.32.2. Methods

20.32.2.1. addMultiplayerSession

Summary

Modifies the MultiplayerSession object to delay its messages.

Syntax

simulator.addMultiplayerSession(multiplayerSession);