Support/Live Chat/Web Client/Events

From MozillaWiki
Jump to: navigation, search

All communication between the Javascript frontend and Java backend takes place via Events. Each web client component defines one or more types of events, each with one or more parameters.

All backend communication of events is handled by org.mozilla.support.chatapp.EventServlet, which converts events to and from JSON representation for communication.

Full documentation is available in the Event Javadoc

  • Event objects are created by widgets and components and are the basis of all AJAX communication
  • Events are communicated to listening components in both Javascript and Java, being communicated over ajax if isAjaxEvent is true.
  • Event priority determines when an event is dispatched over Ajax. (0=immediately, 1=next loop iteration, 2=with next event)
  • There are two types of events used, 'Origin' and 'Target'.
    • Origin events are those being communicated by a component to many other components. They are dispatched to all components listening to the originating component.
    • Target events are commands targeted at a specific widget/component, such as draw events. Other components can register as as a 'spy' to listen to target events for a component.
  • Each event has an unlimited number of named parameters, which can have special meanings for each event.
  • Events are converted to JSON when being communicated over AJAX.