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 void
close()
closes the socket of the serverlong
getLastContact()
"getter" for the last contact of the serverjava.lang.String
getMyName()
"getter" for the nickname of the playerServer
getServer()
"getter" for the serverjava.net.Socket
getSocket()
"getter" for the socketint
getThreadId()
"getter" for the id of the threadvoid
open()
opens the Input- and OutputStream for the socketvoid
run()
run method listens to the input stream, processes the data that it receivesvoid
send(IMessage msg)
method of the sending of a messagevoid
setMyName(java.lang.String myName)
"setter" for the nickname of the playervoid
updateLastContact()
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:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
open
public void open() throws java.io.IOException
opens the Input- and OutputStream for the socket- Throws:
java.io.IOException
- exception for wrong input
-
close
public void close() throws java.io.IOException
closes 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
-
-