Overview of How Regions Work
From OpenSimulator
m (→Source Enabled) |
m (Robot: Cosmetic changes) |
||
Line 1: | Line 1: | ||
− | The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. | + | The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. It's archived here so that hopefully others can benefit from it. |
== Scene: the Core of the Region == | == Scene: the Core of the Region == | ||
− | OpenSim.Region.Framework.Scenes.Scene is the "heart" of OpenSimulator's functionality. | + | OpenSim.Region.Framework.Scenes.Scene is the "heart" of OpenSimulator's functionality. The method Scene.Heartbeat() starts the heartbeat going; it does this by calling the Update() method. That method is the "main loop" of the region: |
<source lang=csharp> | <source lang=csharp> | ||
Line 13: | Line 13: | ||
</source> | </source> | ||
− | That loop is run over and over again. | + | That loop is run over and over again. At the bottom of the loop is: |
<source lang=csharp> | <source lang=csharp> | ||
Line 25: | Line 25: | ||
</source> | </source> | ||
− | In other words, if everything else didn't take as long as one heartbeat is supposed to take, the thread goes to sleep until it's time to service the next heartbeat. | + | In other words, if everything else didn't take as long as one heartbeat is supposed to take, the thread goes to sleep until it's time to service the next heartbeat. This heartbeat runs about 10 times a second. |
− | Other modules of all sorts can register heartbeat events that get called each pass through the main loop, and there are other events that modules can register for as well. | + | Other modules of all sorts can register heartbeat events that get called each pass through the main loop, and there are other events that modules can register for as well. (Details forthcoming....) |
== Which regions run? == | == Which regions run? == | ||
− | The <tt>bin/Regions/Regions.ini</tt> file determines which regions run. | + | The <tt>bin/Regions/Regions.ini</tt> file determines which regions run. Here's an example: |
<source lang=ini> | <source lang=ini> |
Revision as of 19:53, 3 March 2012
The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. It's archived here so that hopefully others can benefit from it.
Scene: the Core of the Region
OpenSim.Region.Framework.Scenes.Scene is the "heart" of OpenSimulator's functionality. The method Scene.Heartbeat() starts the heartbeat going; it does this by calling the Update() method. That method is the "main loop" of the region:
public override void Update() { int maintc = 0; while (!shuttingdown) {
That loop is run over and over again. At the bottom of the loop is:
maintc = Environment.TickCount - maintc; maintc = (int)(m_timespan * 1000) - maintc; if ((maintc < (m_timespan * 1000)) && maintc > 0) Thread.Sleep(maintc); } }
In other words, if everything else didn't take as long as one heartbeat is supposed to take, the thread goes to sleep until it's time to service the next heartbeat. This heartbeat runs about 10 times a second.
Other modules of all sorts can register heartbeat events that get called each pass through the main loop, and there are other events that modules can register for as well. (Details forthcoming....)
Which regions run?
The bin/Regions/Regions.ini file determines which regions run. Here's an example:
[Test] RegionUUID = 4b516a07-aa32-47e4-b4d9-52116255b4d2 Location = 1000,1000 InternalAddress = 127.0.0.1 InternalPort = 9000 AllowAlternatePorts = False ExternalHostName = SYSTEMIP MasterAvatarFirstName = Master MasterAvatarLastName = Avatar MasterAvatarSandboxPassword = master_avatar_password