Alerting system

From OSPDocs

Jump to: navigation, search

Overview

Alerts are used to notify the players of things they must know immediately. The types of alerts present are declared in the class org.usip.oscw.communications.Alert. The following alert types are defined:

  1. ANNOUNCEMENT
  2. PHASECHANGE
  3. NEWS
  4. EVENT

For each running simulation a set of Alert objects will be created and stored. Some alerts will to all players (such as phase changes and general announcements) others are targeted to specific characters.

There are three types of information associated with an alert:

  • A pop-up message may notify the applicable players of the alter.
  • A text page (Announcements, Events or a Specific News Page) may contain information on the event
  • An email may be sent to the players in some cases, for example for a phase change event.

Producing Alerts

An alert can produced in the following ways:

  1. Control may make an announcement
  2. Control may push an inject
  3. Control may make the phase change
  4. A player may modify a document that other players are subscribed to receive change notification

When an Alert is created for a simulation, it will have a unique id assigned to it by hibernate. These ids are sequentially increasing integers, so an Alert with an id 10 will follow after an Alert with an id of 9.

Different RunningSimulations that are running on the same platform may have Alerts interspersed in the same Alert table. Alerts 8 and 10 may belong to Running Simulation 'Alpha' and Alert #9 may belong to RunningSimulation 'Beta.' But this does not matter. All that we are using the ids for is to keep an ordered list, and to keep track of what the highest Alert has been read.


Consuming Alerts

The following sequence of events explains how Alerts are consumed.

  • When a player logs into the system, the highest number of Alert that they have seen is pulled out of the UserAssignment object. This is stored in their PlayerSessionObject as myHighestAlertNumber.
  • Once a player has logged completely into a simulation, the web page the are on (simwebui.jsp) will have a hidden frame (hidden_frame.jsp).
  • The file hidden_frame.jsp has a javascript function in it to tell it to keep polling for new events. It will poll for events from the jsp file sim_event_server.jsp.
  • If the Alert number found in the session context cache () is found to be higher than the number that the player has stored as myHighestAlertNumber, then the next highest Alert is pulled from the server and checked for applicability to this player.
  • If the Alert is applicable to this player it is displayed to them.
  • The player's myHighestAlertNumber is then incremented upward.