Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## it.gotoandplay.smartfoxserver.extensions.examples
Class SimpleExtension

    java.lang.Object
      it.gotoandplay.smartfoxserver.extensions.AbstractExtension
          it.gotoandplay.smartfoxserver.extensions.examples.SimpleExtension

All Implemented Interfaces:
  it.gotoandplay.smartfoxserver.events.IEventListener, it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

    public class SimpleExtension

extends AbstractExtension

This is the most simple SmartFoxServer extension possible.
In a nutshell, every extension has to accomplish four different tasks:

- Initialize
- Handle client requests
- Handle events dispatched by the Server
- Destroy and release its resources

Extensions must implement the following methods:

- init() - here goes all your custom initialization code
- destroy() - this is invoked by the Server before shutting down the extension. Here you should release all the resources (close files, stop Timers and Threads etc...) that the extension uses
- handleRequest() - handles requests coming from the client
- handleInternalEvent() - handles the events dispatched by the Server

Author:
  Marco

Field Summary

Fields inherited from class it.gotoandplay.smartfoxserver.extensions.AbstractExtension
`adminExtension`

Constructor Summary
`SimpleExtension()`

Method Summary
`void` | `destroy()` Destroy the extension
`void` | `handleInternalEvent(InternalEventObject ieo)` Handles an event dispateched by the Server
`void` | `handleRequest(java.lang.String cmd, ActionscriptObject ao, User u, int fromRoom)` Handle client requests sent in XML format.
`void` | `handleRequest(java.lang.String cmd, java.lang.String[] params, User u, int fromRoom)` Handle client requests sent in String format.
`void` | `init()` Initialize the extension.

Methods inherited from class it.gotoandplay.smartfoxserver.extensions.AbstractExtension
`getOwnerRoom, getOwnerZone, handleInternalRequest, handleRequest, isActive, loadConfig, registerForEvents, sendResponse, sendResponse, sendResponse, sendResponse, setActive, setOwner, trace, unRegister`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleExtension

    public SimpleExtension()

Method Detail

### init

    public void init()

  Initialize the extension.
  It's always good practice to keep a reference to the ExtensionHelper object

  Specified by:
    `init` in interface `it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension`
  Overrides:
    `init` in class `AbstractExtension`

### destroy

    public void destroy()

  Destroy the extension

  Specified by:
    `destroy` in interface `it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension`
  Overrides:
    `destroy` in class `AbstractExtension`

### handleRequest

    public void handleRequest(java.lang.String cmd,
                              ActionscriptObject ao,
                              User u,
                              int fromRoom)

  Handle client requests sent in XML format. The AS objects sent by the client are serialized to an ActionscriptObject

  Parameters:
    `ao` - the ActionscriptObject with the serialized data coming from the client
    `cmd` - the cmd name invoked by the client
    `fromRoom` - the id of the room where the user is in
    `u` - the User who sent the message

### handleRequest

    public void handleRequest(java.lang.String cmd,
                              java.lang.String[] params,
                              User u,
                              int fromRoom)

  Handle client requests sent in String format. The parameters sent by the client are split in a String[]

  Parameters:
    `params` - an array of data coming from the client
    `cmd` - the cmd name invoked by the client
    `fromRoom` - the id of the room where the user is in
    `u` - the User who sent the message

### handleInternalEvent

    public void handleInternalEvent(InternalEventObject ieo)

  Handles an event dispateched by the Server

  Parameters:
    `ieo` - the InternalEvent object

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD