This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
Content Creation
Materials
Unigine Material Library
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Basic Network Functionality

Base Network Plugin Functions

With the following functions, you can adjust the work of Network plugin and its modules.

  • void network.setUpdateRate(int update_rate) — sets the network update rate (how many milliseconds should pass before the network is updated). By default update_rate equals 30 ms.
  • int network.getUpdateRate() — gets the current network update rate (in ms).
  • int network.getUpdateTime() — returns the time that the last network update took (in ms).
  • int network.getSyncTime() — returns the time that the processing of the network messages queue took (in ms) during the sync() stage.
  • void network.setMaxEventsPerFrame(int max_events) — sets the limit for the maximum number of messages that can be processed during one sync() call. (All messages that exceed this limit will be processed during the next sync() call). By default max_events limit is equal to 1000 messages.
  • int network.getMaxEventsPerFrame() — gets the limit for the maximum number of messages that can be processed during one sync() call.
  • void network.setMaxSyncTimePerFrame(int max_sync_time) — sets the limit for the maximum duration of sync() (in ms). By default it is equal to 10 ms.
  • int network.getMaxSyncTimePerFrame() — gets the limit for the maximum duration of sync() (in ms).
  • int network.getNumProcessedEvents() — gets the number of processed network messages during the last sync() call.
  • int network.getEventsQueueSize() — gets the number of unprocessed network messages (that have remained in the queue) during the last sync() call.

Network Time Functions

Network time is the time synchronized between the nodes using RakNet. This time allows for calculating packet latency. It is also to synchronize states between the server and a client.

  • long network.getNetworkTime() — returns the current network (synchronized) time in ms
  • long network.getNetworkTimeUS() — returns the current network (synchronized) time in ns

Samples

Example of calculating latency of messages send between a client and a server can be found under <UnigineSDK>/data/network/samples/latency folder.

ResourceMonitor Class

This class creates utility for measuring the usage of processor and memory resources.

  • ResourceMonitor() — a constructor.
  • int getMemoryUsage() — gets memory usage by the current process. In Windows OS this function returns the working set.
  • int getCpuUsage() — gets CPU usage by the current process (%). It is measured in-between the calls, and therefore when being called for the first time, it always returns -1.
Last update: 2017-07-03
Build: ()