netbattle
Class BattleServer

java.lang.Object
  extended by netbattle.BattleServer
All Implemented Interfaces:
java.lang.Runnable

public class BattleServer
extends java.lang.Object
implements java.lang.Runnable


Nested Class Summary
static class BattleServer.BattleServerException
           
static class BattleServer.ChatQueueItem
          Entry in the chat log queue.
 
Field Summary
static int SERVER_VERSION
          Version of the server.
 
Constructor Summary
BattleServer(java.lang.String name, java.lang.String description, java.lang.String unique, int port, int capacity, java.lang.Class mechanics)
          Creates a new instance of BattleServer
 
Method Summary
 void banClient(NetClient mod, java.lang.String name, long date)
           
 void banClient(NetClient mod, java.lang.String name, long date, java.lang.String message)
          Ban a client by name.
 void broadcast(NetMessage msg)
          Broadcast a message to all clients.
 NetClient getClientByName(java.lang.String name)
          Get a client by his user name.
 int getClientCount()
          Return the number of clients.
 java.lang.String[] getClientNames(int[] level, int[] status)
          Get a list of user names.
 java.lang.Class getMechanicsClass()
          Get the default mechanics for battles on the server.
 int getPort()
          Get the port this server is running on.
 java.lang.String getServerName()
           
 UserTableMessage getUserInformation()
          Get a list of users and their information on this server.
 java.lang.String getWelcomeText()
          Get the text of the welcome message from disc.
 boolean isLoggedOn(java.lang.String name)
          Determine whether a user is logged on.
 void kickClient(NetClient mod, java.lang.String name)
          Kick a client by name.
 void removeClient(NetClient client)
          Remove a client.
 void removeFromMetaserver()
          Remove server from the metaserver.
 void run()
          Run the server.
 void sendChatMessage(java.lang.String message)
          Send a chat message to all clients.
 void sendChatMessage(java.lang.String message, boolean important)
           
 void setUserLevel(java.lang.String user, int level)
          Set the level of a user.
 void setWelcomeText(java.lang.String text)
          Set the text of the welcome message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVER_VERSION

public static final int SERVER_VERSION
Version of the server.

See Also:
Constant Field Values
Constructor Detail

BattleServer

public BattleServer(java.lang.String name,
                    java.lang.String description,
                    java.lang.String unique,
                    int port,
                    int capacity,
                    java.lang.Class mechanics)
Creates a new instance of BattleServer

Method Detail

getMechanicsClass

public java.lang.Class getMechanicsClass()
Get the default mechanics for battles on the server.


getServerName

public java.lang.String getServerName()

removeFromMetaserver

public void removeFromMetaserver()
Remove server from the metaserver.


run

public void run()
Run the server.

Specified by:
run in interface java.lang.Runnable

setWelcomeText

public void setWelcomeText(java.lang.String text)
                    throws BattleServer.BattleServerException
Set the text of the welcome message.

Throws:
BattleServer.BattleServerException

getWelcomeText

public java.lang.String getWelcomeText()
                                throws BattleServer.BattleServerException
Get the text of the welcome message from disc.

Throws:
BattleServer.BattleServerException

getPort

public int getPort()
Get the port this server is running on.


getClientCount

public int getClientCount()
Return the number of clients.


getClientNames

public java.lang.String[] getClientNames(int[] level,
                                         int[] status)
Get a list of user names.


kickClient

public void kickClient(NetClient mod,
                       java.lang.String name)
Kick a client by name.


banClient

public void banClient(NetClient mod,
                      java.lang.String name,
                      long date)

sendChatMessage

public void sendChatMessage(java.lang.String message)
Send a chat message to all clients.


sendChatMessage

public void sendChatMessage(java.lang.String message,
                            boolean important)

banClient

public void banClient(NetClient mod,
                      java.lang.String name,
                      long date,
                      java.lang.String message)
Ban a client by name.


getClientByName

public NetClient getClientByName(java.lang.String name)
Get a client by his user name.


isLoggedOn

public boolean isLoggedOn(java.lang.String name)
Determine whether a user is logged on.


removeClient

public void removeClient(NetClient client)
Remove a client.


setUserLevel

public void setUserLevel(java.lang.String user,
                         int level)
Set the level of a user.


getUserInformation

public UserTableMessage getUserInformation()
Get a list of users and their information on this server.


broadcast

public void broadcast(NetMessage msg)
Broadcast a message to all clients.