|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
checkers.view.NetworkView
public class NetworkView
Observes model, and sends any changes over the network. When a change is received, it imitates the GUI by generating the same ActionEvents as if the change happened locally. This makes networking transparent to the controller.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static int |
PORT_NUM
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface checkers.CheckersConstants |
---|
ACCEPT, BLUE, CLIENTGAME, DRAW, HOST, HOSTGAME, JOIN, KING, LOCAL, LOCALGAME, NUM_SPACES, PLAYER1SET, PLAYER2SET, RESIGN, SINGLE, UPDATE, WHITE |
Constructor Summary | |
---|---|
NetworkView(java.util.Observable a1,
java.util.Observable a2,
int color)
Registers Actionlisteners and sets player1color |
Method Summary | |
---|---|
void |
addActionListener(java.awt.event.ActionListener a)
Allows for spoofed Actions to be sent to the controller |
void |
connectToHost(java.lang.String ip)
Connects to specified IP address and starts the network thread. |
void |
hostGame()
Starts hosting a game and waits for a remote client to connect. |
void |
run()
Network thread, sets up the network and receives packets and handles them appropriately. |
void |
setNetwork()
Registers networkView with observables. |
void |
setPlayerName(int num,
java.lang.String name)
Sets the player's name so it can be sent over the network on initial handshake. |
void |
stopHostListening()
Cancel Host Listening without closing the program. |
void |
update(java.util.Observable arg0,
java.lang.Object arg1)
Recievees updates from the model and sends them over the network. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int PORT_NUM
Constructor Detail |
---|
public NetworkView(java.util.Observable a1, java.util.Observable a2, int color)
Method Detail |
---|
public void connectToHost(java.lang.String ip)
ip
- ip to connect topublic void hostGame()
public void stopHostListening()
public void setNetwork()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void addActionListener(java.awt.event.ActionListener a)
a
- controllerpublic void update(java.util.Observable arg0, java.lang.Object arg1)
update
in interface java.util.Observer
arg0
- arg1
- public void setPlayerName(int num, java.lang.String name)
num
- player numname
- player name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |