src.modules
Class WordGameModule

java.lang.Object
  extended bysrc.server.ModuleClass
      extended bysrc.modules.WordGameModule
All Implemented Interfaces:
Module

public class WordGameModule
extends ModuleClass

Provides a simple little word game. The object of the game is to take letters provided by the module and form a word. The number of letters that should be provided by the server can be specified in the query. The time that the user has to make a word is timelimited. The module shows the modules' ability to remember things about users and have a time perception. Example queries:

.*ny.* ordspel.* (\d+) .*(ställnin.*ordspel|orspel.*ställning) ordspel\w* (\w+) TODO highscore? TODO handle timout

Version:
2005-maj-06

Constructor Summary
WordGameModule()
          Constructor for WordGameModule.
 
Method Summary
 boolean isValidCache(ModuleQuery query, java.lang.String cachedUserId, long cacheAge)
          Checks if a cached result is valid or not based on how long ago the result was cached.
 Package processQuery(ModuleQuery query)
          Process a user sent query.
 Package processSettingRequest(QueryPackage query)
          This is the default setting handler.
 
Methods inherited from class src.server.ModuleClass
getModuleMeta, processSettingRequest, setModuleMeta
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordGameModule

public WordGameModule()
Constructor for WordGameModule.

Method Detail

isValidCache

public boolean isValidCache(ModuleQuery query,
                            java.lang.String cachedUserId,
                            long cacheAge)
Description copied from interface: Module
Checks if a cached result is valid or not based on how long ago the result was cached. Some services might work fine with returning very old cached results, for instance the result of a map service wont change (often at least) and most cache ages would then be valid. Other things like news services on the other hand should not allow a long cache age.

Parameters:
query - The user query that resulted in the cached result. The user's query parameters are identical to the cached query parameters.
cachedUserId - The userId of the query that is cached.
cacheAge - The number of seconds that has elapsed since the cached version was cached.
Returns:
True if the cache should be concidered to still be valid. False otherwise.

processQuery

public Package processQuery(ModuleQuery query)
Description copied from interface: Module
Process a user sent query. This is very individual depending on the service provided by the module.

Parameters:
query - The user sent query.
Returns:
An ErrorPackage if an error occured while processing the query, an OutputPackage with the result otherwise.

processSettingRequest

public Package processSettingRequest(QueryPackage query)
Description copied from class: ModuleClass
This is the default setting handler. Most modules will want to use this as this basically does everything for htem. For some modules though they'll want to override this to provide their own checks / handling etc. Saves the setting as moduleClassName_settingName to avoid name conflicts.

Specified by:
processSettingRequest in interface Module
Overrides:
processSettingRequest in class ModuleClass
Parameters:
query - The query to be processed.