|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectClient.ClientModel
public class ClientModel
The ClientModel does not have any race conditions because any method that changes the model state is synchronized. The methods that request information from the server mostly call the sendMessage method which is synchronized. The methods that do not call that method or makes additional changes to the state is synchronized as a method. All instance variables are private and can only be accessed through synchronized methods.
| Nested Class Summary | |
|---|---|
class |
ClientModel.ClientRunnable
Class for creating the background thread. |
class |
ClientModel.ServerOutputThread
This class is used to get the outputs from the server when given certain inputs. |
| Constructor Summary | |
|---|---|
ClientModel()
Constructor used when the default localhost and port is used |
|
ClientModel(boolean isTesting)
Constructor only used in testing Not calling the view at all at this stage The only difference is that the testing constructor does not call the background thread responsible for calling the ClientView. |
|
ClientModel(java.lang.String server,
int port)
|
|
ClientModel(java.lang.String server,
int port,
boolean isTesting)
For testing whether the server is connected to a correct connection. |
|
| Method Summary | |
|---|---|
void |
addme(java.lang.String convId)
Adds the current user to a conversation |
void |
logout()
Closes all connections upon logging out |
void |
removeme(java.lang.String convId)
Removes the user from the conversation |
void |
requestUsername(java.lang.String username)
Requests the username that you want when you first log in to the client. |
void |
sendConvoInvite(java.lang.String convId,
java.lang.String otheruser)
Invites a user into a conversation that has already been initiated |
void |
sendText(java.lang.String message,
java.lang.String convId)
Sends a message in a conversation |
void |
startConversation(java.lang.String[] users)
Starts a conversation with a list of users you pass in to the conversation Need to synchronize because uses users which could be used elsewhere |
void |
usersOnline()
Asks who is in the conversation |
void |
whoInConv(java.lang.String convId)
Asks server who is in the conversation |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ClientModel(java.lang.String server,
int port)
throws java.net.UnknownHostException,
java.io.IOException
java.net.UnknownHostException
java.io.IOException
public ClientModel()
throws java.net.UnknownHostException,
java.io.IOException
java.io.IOException
java.net.UnknownHostExceptionpublic ClientModel(boolean isTesting)
isTesting - whether the testing constructor is called
public ClientModel(java.lang.String server,
int port,
boolean isTesting)
throws java.net.UnknownHostException,
java.io.IOException
isTesting -
java.net.UnknownHostException
java.io.IOException| Method Detail |
|---|
public void requestUsername(java.lang.String username)
username - the username you want to be sent to the serverpublic void startConversation(java.lang.String[] users)
users - the array of users to start a conversation with
public void sendConvoInvite(java.lang.String convId,
java.lang.String otheruser)
convId - the ID of the conversation you want to invite the user intootheruser - the username of the other user you want to invitepublic void addme(java.lang.String convId)
convId - the conversation ID of the conversation to be invited topublic void removeme(java.lang.String convId)
convId - the conversation id of the conversation that the user wants to
be removed frompublic void usersOnline()
public void whoInConv(java.lang.String convId)
convId - the id of the conversation that you want to find out
public void sendText(java.lang.String message,
java.lang.String convId)
message - the message to be sent in the conversationconvId - the conservation where the text will be sentpublic void logout()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||