Package pacManReloaded.server
Class ServerThread
- java.lang.Object
-
- java.lang.Thread
-
- pacManReloaded.server.ServerThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class ServerThread extends java.lang.Thread
-
-
Constructor Summary
Constructors Constructor Description ServerThread(Server serverx, java.net.Socket socketx)Constructor of the server thread
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()closes the socket of the serverlonggetLastContact()"getter" for the last contact of the serverjava.lang.StringgetMyName()"getter" for the nickname of the playerServergetServer()"getter" for the serverjava.net.SocketgetSocket()"getter" for the socketintgetThreadId()"getter" for the id of the threadvoidopen()opens the Input- and OutputStream for the socketvoidrun()run method listens to the input stream, processes the data that it receivesvoidsend(IMessage msg)method of the sending of a messagevoidsetMyName(java.lang.String myName)"setter" for the nickname of the playervoidupdateLastContact()updates the last contact of the server in milliseconds-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
ServerThread
public ServerThread(Server serverx, java.net.Socket socketx)
Constructor of the server thread- Parameters:
serverx- the serversocketx- the socket of the server
-
-
Method Detail
-
run
public void run()
run method listens to the input stream, processes the data that it receives- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
open
public void open() throws java.io.IOExceptionopens the Input- and OutputStream for the socket- Throws:
java.io.IOException- exception for wrong input
-
close
public void close() throws java.io.IOExceptioncloses the socket of the server- Throws:
java.io.IOException- exception if socket isnt closed correctly
-
send
public void send(IMessage msg)
method of the sending of a message- Parameters:
msg- - the message
-
getServer
public Server getServer()
"getter" for the server- Returns:
- - the server
-
getThreadId
public int getThreadId()
"getter" for the id of the thread- Returns:
- - the id of the thread
-
getMyName
public java.lang.String getMyName()
"getter" for the nickname of the player- Returns:
- - nickname of the player
-
setMyName
public void setMyName(java.lang.String myName)
"setter" for the nickname of the player- Parameters:
myName- - nickname of the player
-
getLastContact
public long getLastContact()
"getter" for the last contact of the server- Returns:
- - last contact of the server (the time)
-
updateLastContact
public void updateLastContact()
updates the last contact of the server in milliseconds
-
getSocket
public java.net.Socket getSocket()
"getter" for the socket- Returns:
- - the socket
-
-