Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 1.3 KB

File metadata and controls

21 lines (17 loc) · 1.3 KB

PlaygroundJS

Our server is driven by PlaygroundJS, Las Venturas Playground's proprietary SA-MP plugin that enables (parts of) the gamemode to be written in JavaScript. It includes a copy of the V8 JavaScript engine, and provides modules for support ranging from accessing MySQL databases to creating raw sockets.

Concepts

Deferred callbacks

The callbacks.txt file contains the callbacks that will be delivered as events to JavaScript. Each of them supports annotations, which influences how the event will be dispatched. One of such annotations is Deferred.

When a callback has been deferred, the event handler will not be invoked automatically. Instead, it will be stored internally, in a list that can be obtained by calling getDeferredEvents(). This allows the JavaScript code to dispatch the events at a lower rate (e.g. at 10Hz rather than 200Hz), or apply scheduling techniques to balance out load at times of peak usage.

The DeferredEventManager is responsible for reading the deferred events at a configured interval, and dispatching the events to other parts of the code instead. This allows the full execution path to be completely optimised.