snifos.application
Interface Application

All Superinterfaces:
java.lang.Runnable
All Known Implementing Classes:
DummyApplication, SoccerApp

public interface Application
extends java.lang.Runnable

This interface describes main application class for applications designed for SNIFOS application server.

Version:
$Id: Application.java,v 1.2 2004/05/08 21:55:29 mwerla Exp $

Method Summary
 void configure(java.util.Properties configuration, boolean isUnique)
          Configures instance of Application with given parameters.
 void receiveMessage(UserId userId, org.dom4j.Document message)
          Called by server to pass message from user to this instance of application.
 void registerUser(UserId userId, org.dom4j.Document message)
          Registers user with given id.
 void setServer(Server server)
          Sets instance of server which will be used to communicate with to users.
 void unregisterUser(UserId userId)
          Unregisters user with given id (for example after user disconnects).
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

configure

public void configure(java.util.Properties configuration,
                      boolean isUnique)
               throws ConfigurationException
Configures instance of Application with given parameters.

Parameters:
configuration - Configuration which will be used.
isUnique - True if application is uniqe.
Throws:
ConfigurationException - Thrown when configuration is malformed or cannot be used for some reason.

setServer

public void setServer(Server server)
Sets instance of server which will be used to communicate with to users.

Parameters:
server - Server instance.

unregisterUser

public void unregisterUser(UserId userId)
                    throws InvalidUserException
Unregisters user with given id (for example after user disconnects).

Parameters:
userId - Id of user.
Throws:
InvalidUserException - Thrown when problem with deregistering occurs.

registerUser

public void registerUser(UserId userId,
                         org.dom4j.Document message)
                  throws InvalidUserException
Registers user with given id.

Parameters:
userId - Id of user to register.
message - First message sent by user (can contain some user specific informations)
Throws:
InvalidUserException - Thrown when user cannot be registered by given application instance

receiveMessage

public void receiveMessage(UserId userId,
                           org.dom4j.Document message)
                    throws InvalidUserException
Called by server to pass message from user to this instance of application. If message is invalid for some reason, application should send message to the user with proper information - throwing an exception is not advised.

Parameters:
userId - Id of user which sends message.
message - Received message.
Throws:
InvalidUserException - Thrown when user id is invalid.


Copyright © 2001-2004 MoMaT & MWe Team. All Rights Reserved.