Table Of Contents

Previous topic

21.31. The NetworkLatencyBehavior Object

Next topic

21.33. The Observer Object

This Page

21.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") }}*/

21.32.1. Constructor

21.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.

21.32.2. Methods

21.32.2.1. addMultiplayerSession

Summary

Modifies the MultiplayerSession object to delay its messages.

Syntax

simulator.addMultiplayerSession(multiplayerSession);