QJCC homepage

biz.chitec.qdemo.chat.server
Class QJChatServer

java.lang.Object
  extended byjava.lang.Thread
      extended bybiz.chitec.quarterback.gjsa.server.GJSAServer
          extended bybiz.chitec.qdemo.chat.server.QJChatServer
All Implemented Interfaces:
java.lang.Runnable

public class QJChatServer
extends GJSAServer

A demonstrational GJSA server implementing a chat server. This server class tries to implement a minimalistic GJSA server with the minimal possible overhead. Look at the source code documentation to understand what is going on...

Version:
$Id: d63ffe7b5cd0ef4d3879dea3f443a3aca1b0b151 $
Author:
chitec/Dirk Hillbrecht 2002. Distributed under the terms of the GNU LGPL.

Nested Class Summary
 
Nested classes inherited from class biz.chitec.quarterback.gjsa.server.GJSAServer
GJSAServer.SocketListeningThread
 
Field Summary
private  Logger chatmessagelogger
          Logger for the actual chat messages.
private  java.util.Map chatters
          List of currently connected chatters
static int DEFAULT_PORT
          Standard port for this server.
static java.lang.String FILEPATH
          Path to send and receive files from and to
 
Fields inherited from class biz.chitec.quarterback.gjsa.server.GJSAServer
adminmsg, anyvalue, clie, clsupport, initialexecutoradder, logfilewriter, mainpl, mess, mykiller, objpl, objsslpl, port, secondarypl, serversocket, serverstatesymbols, serverthreadbases, sslavailable, sslpl, sti, utf8pl, utf8sslpl, vulture
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
QJChatServer(java.lang.String[] args)
          Server constructor.
 
Method Summary
 void addChatter(java.lang.String chatter, java.net.InetAddress clientaddress, byte[] chaticon)
          Insert a chatter into the global list.
 java.lang.String getAddon()
          Gets the version addon attribute of the QJChatServer object.
 Logger getChatMessageLogger()
          Gets the chatmessagelogger object of the QJChatServer.
 java.util.List getChatterList()
          Method for obtaining all the chatters as a list.
 int getPatchLevel()
          Gets the patchLevel attribute of the QJChatServer object.
protected  java.lang.String getSaveFileName()
          Gets the name of the properties file.
 java.lang.String getServerName()
          Return this server's name.
 int getSubVersion()
          Gets the subVersion attribute of the QJChatServer object.
 int getVersion()
          Gets the version attribute of the QJChatServer object.
static void main(java.lang.String[] args)
          The main program.
 void removeChatter(java.lang.String chatter)
          Removes a chatter from the list.
 void sendChatMessage(java.lang.String chatter, java.lang.String chatmessage, java.util.List receiver, byte[] chaticon)
          Spread a chat message.
protected  void showHelp()
          Show some help text.
 
Methods inherited from class biz.chitec.quarterback.gjsa.server.GJSAServer
addDebugException, evalArgument, exitRequest, exitRequest, exitRequest, exitRequest, get, getAdditionalLoggingExecutors, getAdminExecutor, getBoolean, getBoolean, getBuildDate, getCompleteVersionString, getConnectionlessSupported, getDebugExceptions, getInteger, getInteger, getLogger, getLoggerCenter, getPort, getPropertyDescriptions, getSaveNames, getServerStateName, getServerStateSymbol, getServerThreadBaseMap, getString, getString, handleCLEnvelope, isCLSupported, loadArguments, loadFromFile, loadPropertyFileName, objListening, put, putBoolean, putInteger, putLogger, putString, registerThreadBase, releaseThreadBase, remove, removeLogger, restartServices, run, runBootSequence, saveToFile, saveToFile, setInitialExecutorAdder, setPort, setServerThreadInitiator, showLoadedArguments, sslListening, sslObjListening, sslUtf8Listening, startAdditionalServices, startServices, stopExitProcess, stopServices, utf8Listening
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILEPATH

public static final java.lang.String FILEPATH
Path to send and receive files from and to

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
Standard port for this server. Somehow things have to start at any port... This setting will be overridden by the properties file, if that one exists.

See Also:
Constant Field Values

chatters

private java.util.Map chatters
List of currently connected chatters


chatmessagelogger

private Logger chatmessagelogger
Logger for the actual chat messages.

Constructor Detail

QJChatServer

public QJChatServer(java.lang.String[] args)
Server constructor. This constructor shows more or less how a GJSA server has to be set up.

Parameters:
args - The command line parameters. Will be evaluated by the GJSA framework.
Method Detail

getServerName

public java.lang.String getServerName()
Return this server's name. This is a framework method.

Specified by:
getServerName in class GJSAServer
Returns:
The server's name.

getVersion

public int getVersion()
Gets the version attribute of the QJChatServer object. This is a framework method.

Specified by:
getVersion in class GJSAServer
Returns:
The version value

getSubVersion

public int getSubVersion()
Gets the subVersion attribute of the QJChatServer object. This is a framework method.

Specified by:
getSubVersion in class GJSAServer
Returns:
The subVersion value

getPatchLevel

public int getPatchLevel()
Gets the patchLevel attribute of the QJChatServer object. This is a framework method.

Specified by:
getPatchLevel in class GJSAServer
Returns:
The patchLevel value

getAddon

public java.lang.String getAddon()
Gets the version addon attribute of the QJChatServer object. This could include something like "test" if this is a test version of the server. This is a framework method.

Specified by:
getAddon in class GJSAServer
Returns:
The addon value

getSaveFileName

protected java.lang.String getSaveFileName()
Gets the name of the properties file. This file is used for storing the server's settings. This is a framework method.

Specified by:
getSaveFileName in class GJSAServer
Returns:
The saveFileName value

showHelp

protected void showHelp()
Show some help text. Note that these options are evaluated by the GJSA framework. Presenting them here is more or less the wrong place. But as help text inheritance is not implemented in the GJSA framework, this is the only place to give the possible parameters.

Overrides:
showHelp in class GJSAServer

getChatMessageLogger

public Logger getChatMessageLogger()
Gets the chatmessagelogger object of the QJChatServer. This is needed by the DoChatExecutor to register its ServerThreadBase with the Logger so that messages are actually sent to the client.

Returns:
The chatmessagelogger object

sendChatMessage

public void sendChatMessage(java.lang.String chatter,
                            java.lang.String chatmessage,
                            java.util.List receiver,
                            byte[] chaticon)
Spread a chat message. This method is called from DoChatExecutor.query(), more precisely its SENDMESSAGE handling part. As the spreading magic is done within the GJSA and Logger framework, we simply have to write the message appropriately into the chatmessage logger.

Parameters:
chatter - The chatter who issued this message.
chatmessage - The actual message to be broadcast.
chaticon - The adress to the chaticon.

addChatter

public void addChatter(java.lang.String chatter,
                       java.net.InetAddress clientaddress,
                       byte[] chaticon)
Insert a chatter into the global list. Inserts the chatter. Throws CommandException if chatter with same name already exists. It insertion was successful, sends appropriate message through chatmessagelogger so that other clients can see that someone else has joined.

Parameters:
chatter - The name of the chatter to be added
clientaddress - Where does the chatter come from
chaticon - The adress to the chaticon

removeChatter

public void removeChatter(java.lang.String chatter)
Removes a chatter from the list. This is called internally only, so trying to remove a non-existant chatter should not happen. Apart from this, this method works almost similary to adChatter() above.

Parameters:
chatter - Description of the Parameter

getChatterList

public java.util.List getChatterList()
Method for obtaining all the chatters as a list. Traverses the chatters HashMap, creates a List and returns it. The List itself contains HashMaps which are based on the entries of chatters...

Returns:
The list of chatters

main

public static void main(java.lang.String[] args)
The main program. Simply creates an instance of this class. Everything else is done by the constructor.

Parameters:
args - The command line arguments

QJCC homepage