Class gnsd
[ Source
| Index
| Back to GNS
]
- public class gnsd
- extends Object
gnsd - Controls server level functions such as group control, user count,
Loads cofinguration file, and starts the primary server thread that
waits for user connection. A new user thread is spawned for every
open connection. Also handls joining of groups, lists, and user
count.
-
client
- Used to manage incoming client connections.
-
DEBUG
- Tells the server to Output debug information.
-
groups
- Stores information about the current groups.
-
log
- Used to log major commands to
PATH/log/access_log.
-
PATH
- Stores information about where data files are located.
-
PORT
- Stores information about the activate port.
-
QUEUE
- Store information about how many port to queue.
-
userCount
- Stores how many users are on-line currently.
-
gnsd(String)
- Starts the General Network Server.
-
authenticate(int, String)
- Allows the user to authenticate to the server.
-
checkGroup(int)
- Checks to see if a group is already formed.
-
getList(int, User)
- Returns a list of groups back to the user based on their gameID.
-
getPath()
- Returns the servers PATH.
-
getUserCount()
- Gets how many users are currently on-line.
-
join(int, User)
- Allows a user to join a group.
-
joinNew(int, int, String, String, User)
- Will create a new group and allow a user to join it.
-
loadConf(String)
- Allows the server to be configured at runtime.
-
main(String[])
- Tells the Application load.
-
remove(Group)
- Will remove a group from the group vector.
-
setLogger(logger)
- Sets which log class we should use.
-
toInt(String)
- Converts a String to an int;
-
userCount(int)
- Function is used to manage the user count.
log
private logger log
- Used to log major commands to
PATH/log/access_log. This
will log @connect, @login, @join, @joinnew, @list, @part, and @logout.
Logs are timestamped via time_t, information about the user's host,
command, and other useful information is given.
client
private Socket client
- Used to manage incoming client connections.
PATH
private String PATH
- Stores information about where data files are located. Read from the
configuration file.
- See Also:
- loadConf
PORT
private int PORT
- Stores information about the activate port. Default value is 5000, can
be changed through the configuration file.
- See Also:
- loadConf
QUEUE
private int QUEUE
- Store information about how many port to queue. Default value is 512,
can be changed through the configuration file.
- See Also:
- loadConf
DEBUG
private boolean DEBUG
- Tells the server to Output debug information. Useful when you are
trying to build a new game, or just make sure the server is working.
Default value is false, can be changed through the configuration file.
- See Also:
- loadConf
userCount
private int userCount
- Stores how many users are on-line currently.
groups
private static Vector groups
- Stores information about the current groups.
gnsd
public gnsd(String file) throws IOException
- Starts the General Network Server. This is the primary working function,
it loads all configuration variables, starts the server and waits for
new connections.
- Parameters:
- files - Configuration file to be loaded.
- See Also:
- loadConf
main
public static void main(String args[]) throws IOException
- Tells the Application load. This functions makes sure that we have
the proper number of arugments (0 or 1). If we don't have any arugments
the configure files is set to ./gnsd.conf. If an arugment is
given, we use that as the configure file.
setLogger
public final void setLogger(logger l)
- Sets which log class we should use.
getPath
public final String getPath()
- Returns the servers PATH. This is used by sub classes in order to
maintain an acurate data without having to hardcode information.
userCount
public void userCount(int i)
- Function is used to manage the user count. If you call the function
with a +1, a user is added to the count, call it with a -1,
and a user is substracted.
- Parameters:
- i - How many users to add to the count.
getUserCount
public int getUserCount()
- Gets how many users are currently on-line.
- Returns:
- number of users currently on-line.
getList
public void getList(int gID,
User u)
- Returns a list of groups back to the user based on their gameID.
Designed to list all the channels that the player can join and return it
to the user one line at a time. Data sent back to the user is, groupID,
title, mode, and user count.
- Parameters:
- gID - the game ID to match on
- u - Instance of the user so we can send data.
checkGroup
public boolean checkGroup(int cID)
- Checks to see if a group is already formed. This function is used when
the user trys to join a channel. If the channel does not exist,
the @joinnew command must be used. If the @joinnew command wased used
and the channel exists, it's just like using @join.
- Parameters:
- cID - id to check
authenticate
public String authenticate(int uID,
String uPassword)
- Allows the user to authenticate to the server. Loads
PATH/users.dbf and checks to make sure that both the given user
name nad password are correct. users.dbf is a database file seperated
by a ",". Read fields are name, password, ID.
- Parameters:
- uID - the users ID number
- uPassword - the users password
- Returns:
- the players name if ID and password were
correct, logout otherwise.
join
public void join(int cID,
User u)
- Allows a user to join a group. Finds the channel the user request to
join and adds them to the list. If the channel does not exist, a new
"Network" channel is made, this is to handle the auto join feature.
- Parameters:
- cID - the ID of the group to join.
- u - Instance of the User.
joinNew
public void joinNew(int cID,
int gID,
String title,
String mode,
User u)
- Will create a new group and allow a user to join it. Much like the join
function, except this will create a new group for users to join.
- Parameters:
- cID - group ID to create
- gID - game ID from client.
- title - title/topic of the group
- mode - information about the type of channel
- u - Instance of the User.
- See Also:
- join
remove
public void remove(Group g)
- Will remove a group from the group vector. When a channel doesn't have
any more users in it this function allows it to be closed down.
- Parameters:
- g - the group to be closed.
loadConf
private void loadConf(String f)
- Allows the server to be configured at runtime. There are 4 options that
can be set, PATH, PORT, QUEUE, and DEBUG. To set an option, simple use
It's name, a space, and the value of the option, such as PORT 4000. When
you run the General Network Server, you will see all the runtime options
that are set.
- Parameters:
- f - file to load.
toInt
private int toInt(String s)
- Converts a String to an int;
- Parameters:
- s - The String to be converted
- Returns:
- an
int value from s
|