Class Group
[ Source
| Index
| Back to GNS
]
- public class Group
- extends Object
Group - Stores group data and provides fast, easy data exchange between
all members.
A vector of users is kept for each group and users can join or leave
any group that matches their client/gameID.
-
gameID
- The client/game ID that can connect to this group.
-
id
- The groups ID.
-
mode
- Information about the state or other group wide information.
-
server
- An instance of the primary server.
-
title
- The title or topic of the group.
-
toAll
- Determins if data should be sent back to the client it came from.
-
useName
-
-
users
- The Users that are in the group.
-
Group(int, int, String, String, gnsd)
- Creats and instance of a new group with all the required information.
-
addUser(User)
- Adds a user to the group.
-
checkGameID(int)
- Checks to see if the passed ID is equal to the channel gameID.
-
checkID(int)
- Checks to see if the passed ID is equal to the channel ID.
-
getID()
- Gets the group ID.
-
getListData()
- Gets that data that is sent to the client for the list.
-
getMode()
- Gets the group's mode.
-
getTitle()
- Gets the group's title/topic.
-
getUserList()
- Displays the name of all the users that are in the group.
-
removeUser(User)
- Removes a user from the group.
-
sendAll(String, int)
- Transmits data to all members of the group.
-
sendPriv(String, String)
- Sends a private message to only one user of the group.
-
setBroadcastType(boolean)
- Sets the broadcast type.
users
private Vector users
- The Users that are in the group. This allows the server to send them
data when require, to remove them from the group, and to keep an
accurate user count for this channel.
server
private gnsd server
- An instance of the primary server. This is used to perform server
level function, such as the removal of groups from the server.
id
private int id
- The groups ID.
gameID
private int gameID
- The client/game ID that can connect to this group.
title
private String title
- The title or topic of the group.
mode
private String mode
- Information about the state or other group wide information.
toAll
private boolean toAll
- Determins if data should be sent back to the client it came from.
useName
public boolean useName
Group
public Group(int id,
int gID,
String t,
String m,
gnsd s)
- Creats and instance of a new group with all the required information.
The group starts out empty, and no information is sent to the client
about a new group being formed.
- Parameters:
- id - the group id
- gID - the Client/Game ID that can use this group
- t - the group title/topic.
- m - the group mode
- s - Instance of the server.
checkID
public boolean checkID(int cID)
- Checks to see if the passed ID is equal to the channel ID. This is used
by the server when checking if a channel with a given ID exists.
- Parameters:
- cID - the group ID to check
- Returns:
- true if cID == id, false otherwise.
- See Also:
- id
checkGameID
public boolean checkGameID(int gID)
- Checks to see if the passed ID is equal to the channel gameID. This is
used when the server lists channels. If the game ID's don't match,
the channel is not listed.
- Parameters:
- gID - the game ID to check
- Returns:
- true if gID == gameID, false otherwise.
- See Also:
- gameID
setBroadcastType
public void setBroadcastType(boolean b)
- Sets the broadcast type. This allows the client to either request data
it sends back, or not.
- Parameters:
- b - do we want data back?
- See Also:
- toAll
addUser
public void addUser(User u)
- Adds a user to the group. This also sends the join command back to all
clients that are in the group.
- Parameters:
- u - the user to add
removeUser
public void removeUser(User u)
- Removes a user from the group. This also sends the part command back to
all the clients taht are in the group.
- Parameters:
- u - the user to remove.
getID
public int getID()
- Gets the group ID.
- Returns:
- the group ID.
- See Also:
- id
getTitle
public String getTitle()
- Gets the group's title/topic.
- Returns:
- the group's title.
- See Also:
- title
getMode
public String getMode()
- Gets the group's mode.
- Returns:
- the group's mode.
- See Also:
- mode
getUserList
public String getUserList()
- Displays the name of all the users that are in the group. They are
seperated by a "," so the client can easily pick them appart.
- Returns:
- a string that list all the users.
getListData
public String getListData()
- Gets that data that is sent to the client for the list. Data is
"id`title`mode`userCount".
- See Also:
- id, title, mode
sendAll
public synchronized void sendAll(String data,
int uID)
- Transmits data to all members of the group. If toAll is set to fall
the person who sends the data does not get a copy back.
- Parameters:
- data - the message to send
- uID - the user who sent it.
- See Also:
- toAll
sendPriv
public synchronized void sendPriv(String who,
String data)
- Sends a private message to only one user of the group. No Data is
ever sent back to the originating client.
- Parameters:
- who - the person who is going to get the private message.
- data - the private message
|