mud.client.corba
Class ServerConnection

java.lang.Object
  extended by mud.client.corba.ServerConnection

public class ServerConnection
extends java.lang.Object

Create a new ORB and initialize and register the classes

Author:
Tamar Christina

Constructor Summary
ServerConnection(java.lang.String[] args)
          Create a new ServerConnection Instance and pass along the command line arguments
 
Method Summary
 boolean action(int object_id, int action_index)
          Try and perfom an action on the server
 boolean attack()
          Try to perform an attack on something/someone on the server
 ClientImpl getClient()
          Get a reference to the current ClientImp class
 int getSecurityToken()
           
 java.lang.String[] getUsers()
          Gets a list of active users
 boolean login(java.lang.String username, java.lang.String password)
          Try and authenticate to the game server
 void logout()
          Logout from the game server
 boolean move(int x, int y)
          Try and perform a move operation on your player
 void sendMessage(java.lang.String message)
          Sends a chat message to the server
 void start()
          Start the main loop thread
 void stop()
          Stop the orb and kill the main loop
 boolean useItem(int item_id)
          Try and use an item
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerConnection

public ServerConnection(java.lang.String[] args)
Create a new ServerConnection Instance and pass along the command line arguments

Parameters:
args - CommandLine arguments for the program. Used to initialise corba.
Method Detail

getClient

public ClientImpl getClient()
Get a reference to the current ClientImp class

Returns:
ClientImpl class, or Null if connection has not yet been made.

getSecurityToken

public int getSecurityToken()

stop

public void stop()
Stop the orb and kill the main loop


start

public void start()
Start the main loop thread


action

public boolean action(int object_id,
                      int action_index)
               throws AuthenticationException,
                      InvalidSecurityToken
Try and perfom an action on the server

Parameters:
action_index - The id of the action to be performed
Returns:
Whether the action has succeeded or not
Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken
InvalidSecurityToken - When this method is called with an invalid token
InvalidSecurityToken

attack

public boolean attack()
               throws AuthenticationException,
                      InvalidSecurityToken
Try to perform an attack on something/someone on the server

Returns:
Whether the attack has succeeded or not
Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken - When this method is called with an invalid token

login

public boolean login(java.lang.String username,
                     java.lang.String password)
Try and authenticate to the game server

Parameters:
username - Username for a player
password - Password for the player
Returns:
Whether the login was successful

logout

public void logout()
            throws AuthenticationException,
                   InvalidSecurityToken
Logout from the game server

Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken - When this method is called with an invalid token

move

public boolean move(int x,
                    int y)
             throws AuthenticationException,
                    InvalidSecurityToken
Try and perform a move operation on your player

Parameters:
x - New X coordinate
y - New Y coordinate
Returns:
Whether the move was successful or not
Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken - When this method is called with an invalid token

useItem

public boolean useItem(int item_id)
                throws AuthenticationException,
                       InvalidSecurityToken
Try and use an item

Parameters:
item_id - Id of the item to be used
Returns:
Whether the operation was successful or not
Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken - When this method is called with an invalid token

getUsers

public java.lang.String[] getUsers()
                            throws InvalidSecurityToken,
                                   AuthenticationException
Gets a list of active users

Returns:
A List of currently active users
Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken - When this method is called with an invalid token

sendMessage

public void sendMessage(java.lang.String message)
                 throws InvalidSecurityToken,
                        AuthenticationException
Sends a chat message to the server

Parameters:
message - Message to be send
Throws:
AuthenticationException - if user is not logged in
InvalidSecurityToken - When this method is called with an invalid token