|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.eriksilkensen.sudoku.SudokuControl
com.eriksilkensen.sudoku.SudokuNetworkedControl
public class SudokuNetworkedControl
SudokuNetworkedControl is an enhanced version of the default SudokuControl, and so behaves exactly like one would expect of a Control in the M-V-C framework.
NetworkedControl implements the Observer interface so that it can register itself as an Observer of the Observable Client interface. This way, any changes made to the Client (like a message being sent across the network) are brought to the attention of the listening Controls.
This would allow a multi-player game to be played over a network connection.
| Field Summary |
|---|
| Fields inherited from class com.eriksilkensen.sudoku.SudokuControl |
|---|
model, view |
| Constructor Summary | |
|---|---|
SudokuNetworkedControl(SudokuModel model)
The only constructor does everything its super class version does, and then creates a new Client and registers itself with the Client |
|
| Method Summary | |
|---|---|
void |
checkBoard()
Overrides checkBoard() in SudokuControl to notify the other players that this one has won. |
boolean |
connectToNetwork(java.lang.String name)
Attempts to connect to the network, and returns the success of the attempt |
boolean |
disconnectFromNetwork()
Attempts to disconnect from the network, and returns the success of the attempt -> false if the Client wasn't connected in the first place |
protected java.lang.String |
getHost()
|
protected int |
getPort()
|
void |
giveUp()
Overrides giveUp() in SudokuControl to notify the other players that this one has given up. |
void |
newBoard(int ID)
NetworkedControl-specific method for creating a newBoard() which sends out a message with the ID of the Board to be played |
protected void |
setHost(java.lang.String host)
|
protected void |
setPort(java.lang.String port)
|
protected void |
showHideChatRoom()
|
void |
update(Observable obs,
java.lang.Object arg)
This method is called automatically by the Observable Client whenever it needs to call attention to itself. |
void |
windowClosing()
Called by the View when a user is closing their window |
| Methods inherited from class com.eriksilkensen.sudoku.SudokuControl |
|---|
checkForBestTimes, clear, clearTimes, getBestTimes, getBoard, getBoardID, getDifficulty, getIDLimit, getRange, getSolution, getStatus, hint, initGame, isLegalID, loadGame, newBoard, newBoard, newDownloadedBoard, printBoard, printSolution, registerObserver, removeObserver, saveGame, setBoard, setStatusIdle, setStatusPlaying, setTime, start, submitTimes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SudokuNetworkedControl(SudokuModel model)
| Method Detail |
|---|
public void update(Observable obs,
java.lang.Object arg)
The Client sends out Objects, and implements the "push" strategy by pushing along whatever arg it wants to the Observing Control, instead of forcing the Control to "pull" information from the Client. This also means, though, that the Control is responsible for doing the required casting.
update in interface Observerpublic void newBoard(int ID)
newBoard in class SudokuControlpublic void giveUp()
giveUp in class SudokuControlpublic void checkBoard()
checkBoard in class SudokuControlpublic void windowClosing()
windowClosing in class SudokuControlpublic boolean connectToNetwork(java.lang.String name)
connectToNetwork in class SudokuControlpublic boolean disconnectFromNetwork()
disconnectFromNetwork in class SudokuControlprotected void setHost(java.lang.String host)
setHost in class SudokuControlprotected void setPort(java.lang.String port)
setPort in class SudokuControlprotected void showHideChatRoom()
showHideChatRoom in class SudokuControlprotected java.lang.String getHost()
getHost in class SudokuControlprotected int getPort()
getPort in class SudokuControl
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||