Jump to content

OpenSimulator Internals/Code Map/Shared

From Open Simulator Technical Help

OpenSimulator Internals/Code Map/Shared

[edit]

Overview

[edit]

Both ROBUST and OpenSim.exe are built from the same source tree and share the same DLL output. The code listed here is used by both processes -- not just one side calling the other.


Core Data Structures

[edit]
OpenSim/Framework/

Contains the fundamental data types that flow between all parts of the system. Neither ROBUST nor the simulator can function without these.

Key types:

Type Notes
AssetBase Asset metadata and binary data -- passed between asset service and callers
GridRegion Region descriptor -- returned by GridService queries, used by simulator and ROBUST
InventoryItemBase Inventory item -- passed between inventory service and callers
InventoryFolderBase Inventory folder
RegionInfo Region configuration -- loaded from Regions.ini, used by simulator startup
UserAccount User account data -- passed between UserAccountService and callers
UUID OpenMetaverse UUID wrapper -- used everywhere as primary identifier

Also contains utility classes used by both processes:

Class Notes
Util General utilities: coordinate conversion, string helpers, Unix timestamps, UUID parsing
Constants Grid constants: RegionSize, MaximumRegionSize, region coordinate limits
RegionFlags Enum of region flag bitmask values -- used by GridService and simulators
AssetType Enum of asset type numbers
AssetFlags Enum of asset flag bitmask values

Service Interfaces

[edit]
OpenSim/Services/Interfaces/

All service contracts are defined here as C# interfaces. Both ROBUST (which implements them) and the simulator (which calls them) depend on these interfaces. Neither side depends on the other's implementation.

Key interfaces:

Interface Notes
IAssetService Get, Store, Delete, AssetsExist, GetData, GetMetadata
IGridService RegisterRegion, DeregisterRegion, GetRegionByUUID, GetNeighbours, etc.
IInventoryService GetRootFolder, GetFolderItems, AddItem, DeleteItems, etc.
IUserAccountService GetUserAccount, CreateUser, SetUserAccount
IPresenceService LoginAgent, LogoutAgent, GetAgents
IAuthenticationService Authenticate, Verify, SetPassword
IAvatarService GetAvatar, SetAvatar
IFriendsService GetFriends, StoreFriend, Delete
IGridUserService LoggedIn, LoggedOut, SetHome, GetGridUserInfo

In standalone mode, the simulator holds a direct reference to the service implementation. In grid mode, it holds a reference to a remote connector that calls ROBUST over HTTP. The interface is identical either way.


HTTP Server Infrastructure

[edit]
OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
OpenSim/Framework/Servers/MainServer.cs

Both ROBUST and OpenSim.exe run HTTP servers. Both use the same base classes.

Class Notes
BaseHttpServer HTTP listener -- both processes instantiate this. Also contains IndexPHPHandler (line 2276) -- handles GET /index.php requests on the login port. Dispatches on ?method= parameter. Registered by both ROBUST (ServerMain.cs) and the simulator (OpenSim/Region/Application/OpenSim.cs) -- in standalone mode the simulator is its own login server.
MainServer Singleton registry of all running HTTP servers. GetHttpServer(port) creates a server on demand for a given port. MainServer.Instance is the primary server.
BaseStreamHandler Base class for all HTTP handlers that read/write streams
BaseRequestHandler Base class for simpler request handlers
IOSHttpRequest / IOSHttpResponse Request/response abstractions passed to all handlers

Plugin Loading and Serialization

[edit]
OpenSim/Server/Base/ServerUtils.cs

Used by both processes to load plugins and serialize HTTP responses.

Key methods:

Method Notes
LoadPlugin<T>() Loads a class from a DLL by name using .NET reflection -- used by both ROBUST and simulator module loading
BuildXmlResponse() Serializes a Dictionary<string,object> to XML -- used by all ROBUST service handlers
SerializeResult() Serializes an object via XmlSerializer -- used by asset and grid handlers
ParseQueryString() Parses POST body key-value pairs -- used by all ROBUST handlers that accept POST

Database Abstraction Layer

[edit]
OpenSim/Data/
OpenSim/Data/MySQL/

Both processes use the same database abstraction layer, but against different tables:

Interface Used by Tables
IRegionData ROBUST (GridService) regions
IAssetDataPlugin ROBUST (AssetService) assets
IInventoryDataPlugin ROBUST (InventoryService) inventoryfolders, inventoryitems
IUserAccountData ROBUST (UserAccountService) UserAccounts
IPresenceData ROBUST (PresenceService) Presence
ISimulationDataStore OpenSim.exe (Scene) prims, primshapes, terrain, land, estate_*

The MySQL implementations live in OpenSim/Data/MySQL/ and are loaded as plugins at runtime. Both processes use the same plugin loading mechanism -- only the interface and connection string differ.


See Also

[edit]