Crossfire Tools API

From FirebugWiki

Revision as of 19:44, 3 December 2010 by MCollins (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Tools API provides a simple way for extensions to be notified when a Crossfire client or server connects to another host, and allows extensions to use this connection to send and receive custom requests and events over the Crossfire connection.

Contents

Using the Crossfire Tools API

In order to use the Tools API, you need to implement a listener object for your tool, and register it with Crossfire.

Creating a Tool listener

A Tool listener is a Javascript object that should contain a string property, toolName, and implements the following functions:

           handleEvent: function( event) {}           
           handleRequest: function( request) {}            
           onTransportCreated: function( transport) {}            
           onTransportDestroyed: function() {}            
           onRegistered: function() {            
           onUnregistered: function() {}            
           onConnectionStatusChanged: function( status) {}            

Specifying Events and Commands for your tool

The simplest way to specify which commands and events your listener supports is to list the names in an array. Crossfire will check for a commands and an events array as properties of your listener.

Alternatively, your listener can optionally implement the supportsRequest() and/or supportsEvent() methods.

Registering a Tool Listener

In order for your listener to start receiving callbacks and events/requests, you must register it with the Crossfire module. This is accomplished by calling the registerTool method:

   CrossfireModule.registerTool( toolName, toolListener);

If you wish to stop receiving events, you call the unregisterTool method:

   CrossfireModule.unregisterTool( toolName);

The toolName argument should be a string that matches a property named toolName in your listener object. Crossfire will add this string as a header to packets sent to your listener, in order to route packets appropriately to various tools.

Crossfire Transport API

Tool Headers

Handshake

Examples

Console Tool

Inspector Tool

Net Tool

Personal tools