gloebit / opensim-moneymodule-gloebit

OpenSim addon module integrating with the Gloebit digital currency service
GNU Lesser General Public License v3.0
8 stars 12 forks source link

OpenSim Gloebit Money Module

This is a plugin (addon) to enable the Gloebit currency service on an OpenSim grid. It also serves as an example which can be referenced or ported to integrate the Gloebit service with other platforms.

Gloebit Money Module for OpenSim

How to use this with OpenSim

  1. Download or Build the DLL
    • Download\ If you don't want to build yourself, you can download the most recent release of the plugin here. Download the DLL built for or as close to your version of OpenSim as possible. If you run into any linking errors, then either the version of OpenSim or your build environment are incompatible with the prebuilt DLLs and you'll need to build it directly against your repository.
    • or Build\ For the latest features and to ensure compatibility with your system, we recommend building the DLL yourself.
      1. Clone or Download this repository
      2. Copy the Gloebit directory into the addon-modules directory in your OpenSim repository
      3. Install mono and mono-devel version 5.12 or higher
      4. Run the OpenSim runprebuild script eg:. runprebuild.sh
      5. Build OpenSim eb:msbuild or nant
      6. Check build result should not return error or excessive amounts of warnings(3-5 normally)
  2. Configure the plugin
    • Follow the instructions here.

Understanding, Contributing to, and Porting this Plugin

Code Organization - The breakdown of the functional layers

GMM Architecture Slide GMM Architecture Files Slide

Starting with the foundation...

The REST / Web API Layer

This layer provides a C# interface for connecting with Gloebit's web service apis through defined endpoints.

This layer is platform agnostic and shouldn't need modification for porting to another C# platform. However, it does use an older asyncronous C# pattern compatible with earlier versions of mono. If another C# platform did not have those compatibility issues, an alternate version could be written to take advantage of the newer Async and Await calls, though it is unknown if there are any performance gains that would be worth this effort. It also serves as example code for anyone who needs to build a web api for connecting to gloebit in a language other than C#.

Modifications to this layer should really be intended to be universal improvements. Some such improvements on our list are to...

The Object Layer

This layer provides C# classes for more easily managing the data passed to and from the Gloebit API and used throughout the module.

This layer is platform agnostic and shouldn't need modification for porting to another C# platform.

Modifications to this layer would be necessary if there was additional data you wanted to package with the objects or store in database tables. Some such improvements on our list are to...

The Database Interface Layer

This layer handles the storage and retrieval of objects to and from a database.

This layer likely needs modification for porting to another platform. The Data classes are built upon GenericTableHandlers provided by OpenSim and the migration format may be specific to OpenSim. These classes should be modified to work with the database interface of the intended platform so that the storage and retrieval calls from the object classes work as expected.

Integrating a database other than MySql, PGSQL or SQLite would be done here by adding the implementation to each data class and adding a migration for each class to the resources.

The Functional Helper Layer

This layer wraps the API in a more useful functional layer, converts platform specific information into formats expected by the API and vice versa, handles callbacks from the api, http callbacks from the Gloebit service, and errors, and manages as much processing logic as should be generic to all platforms. This layer should drastically simplify integration, and will likely need to evolve as new platforms integrate the plugin. It defines some interfaces which the platform glue layer must implement. Some of these may at some point be converted to events that can be registered for.

This layer is where some editing will be necessary when porting to another platform. The signatures of the http callbacks may be specific to the platform and therefor may need adjustment. In simplifying the returns from the API layer, it is possible we've elimiated information a platform may need, in which case new interface functions may be necessary. We recommend keeping the platform logic out of this layer in these cases and requesting that we adopt new interface functions or argument passing into the root plugin.

The Platform Glue Layer

This layer contains all the connections to the larger platform. It reads configuration, creates the API, registers the http callbacks, defines the platform specific transactions, implements all interfaces necessary for the APIWrapper, and controls the full API flow. This contains the platform specific logic. Currently, this file is both the glue between OpenSim and Gloebit and also a lot of strictly OpenSim logic which could be elsewhere. Ideally we'll better separate this eventually by splitting this class and file up.

This layer is where most of the editing will be necessary when porting to another platform. As much as possible, the GloebitAPIWrapper interface method signatures should be maintained, but the bodies will likely have to be modified.

Adding a new commerce flow in OpenSim

  1. Add a TransactionType enum.
    • Define a new TransationType for the flow which should be supplied by triggering event.
    • Add this TransactionType to the switch statement of a receiving event for processing this flow.
  2. Handle TransactionPrecheckFailures
    • Define any newly necessary TransactionPrecheckFailure enums not already created.
    • Call alertUsersTransactionPreparationFailure() as necessary from the interface function handling processing.
    • Edit alertUsersTransactionPrepartionFailure() as neccessary to provide specific messaging for this new TransactionType.
  3. Compile info to be supplied in user's transaction history on gloebit.com
    • Call buildOpenSimTransactionDescMap
    • If more info is needed, either create a new override for buildBaseTransactionDescMap, or call GloebitAPIWrapper.addDescMapEntry to add elements one at a time to the base map.
    • Create a description string to be displayed as the primary transaction description
  4. Build the Transaction
    • Supply the proper information to buildTransaction().
    • If you will need additional information when processing this transaction which you can not store in the default transaction parameters, then you will need to create a new dictionary to map the transaction UUID to the asset information you'll require.
    • If this is a subscription (auto-debit) transaction, you'll also need to create or retrieve the subscription authorization.
  5. Submit the Transaction to Gloebit
    • Call GloebitAPIWrapper SubmitTransaction() or SubmitSyncTransaction() and supply the transaction, description and descMap for this transaction type.
  6. Implement delivery of asset related to payment (see region GMM IAssetCallback Interface)
    • Add this TransactionType to processAssetEnactHold(), processAssetConsumeHold(), processAssetCancelHold() to handle the particulars of asset delivery for this TransactionType
    • These will be triggered by Gloebit during processing of this transaction
  7. Implement any platform specific functional requirements of transacton process stages not handled in asset enact/consume/cancel via the GloebitAPIWrapper ITransactionAlert interface AlertTransaction functions
  8. Provide messaging to user throughout transaction (see region GMM User Messaging)
    • Add this TransactionType to alertUsersTransactionBegun()
    • As necessary, add this TransactionType to alertUsersTransactionStageCompleted(), alertUsersTransactionFailed() and alertUsersTransactionSucceeded() to supply transaction specific messaging.

Integrating into a new platform

Required Libraries

Configuration

There must be a system for an application to declare the configuration for connecting to the Gloebit service. At a bare minimum, the app needs to define the OAuth key and secret which will identify it to Gloebit and whatever database connection parameters are necessary for the platforms database interface layer.

Initialization

Required Interface Implementation

The following interfaces must be defined and passed to the constructor for the GloebitAPIWrapper

Using the system