Overview

Plugin bundles are the “building blocks” of RSence applications. A bundle is a directory that groups together the software code and its related resources.

Plugin bundles are constructed of at least a directory and a ruby source file either named “main.rb” or the same name as the directory plus + “.rb”.

The main ruby file has to contain at least one class extended from one of the three types of plugins:

Example 1: A very simple plugin bundle structure

simple_plugin/
`-- main.rb

Simplest possible contents of the “main.rb” as above

class SimplePlugin < Plugin
end

A plugin like this just gets registered as a plugin named :simple_plugin when RSence finds it in one of its “plugins” directories. By default, one “plugins” directory is distributed as a part of RSence and contains some core services common to most applications. The other is the “plugins” directory inside your RSence project environment directory.

To make the plugin do something useful, extend its model. To know more about that, just read the documentation about the model classes: Plugin, GUIPlugin, Servlet.

Extending the simple plugin to say “Hello” to your web browser’s javascript console.

class SimplePlugin < Plugin
  def init_ui( msg )
    msg.console( "Hello" )
  end
end

Example 2: The “welcome” GUIPlugin bundle

This example is rather lengthy, so read it here.

Plugin meta-information files

These files are optional parts of a bundle, but are supported by the system. Most bundles will contain several other files as well, as defined by each bundle’s software code.

Supported by all bundle types, including Servlet:

Supported by Plugin and GUIPlugin bundles:

Supported by GUIPlugin bundles:

Values and data transfer

The description is rather lengthy, so it’s in its own document HERE.

Messages and sessions

As a side effect of having the same instances of plugins serve the requests of all sessions, the request/response/session messaging is implemented as messaging objects. These objects contain or delegate all the necessary hooks required by the complete request/response cycle.

The naming convention of the Message instance is msg and it’s given as the first parameter of methods using it directly.

Use msg.session_id to identify the session’s serial number and msg.user_id to identify the user’s identity. Both are Numbers.

Use the msg.session Hash to store any persistent data associated with the user’s session, preferably using the name of the plugin or its registered name as the primary key entry in the Hash. To do so automatically, just call the get_ses method in your Plugin or GUIPlugin.

The session data is persistent; it’s stored in the session database by the main SessionStorage instance automatically, if a database connection string is properly configured.

The msg also provides access to the msg.request and msg.response objects directly, but don’t mess around with them unless you know exactly what you are doing.

Use the @plugins object to call other plugins, like this:

@plugins.plugin_name.method_name( param1, param2 )

To append Javascript source code to be executed in the client, use the msg.reply method. The msg.console method displays debugging messages in the browser’s Javascript console.