|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.joctopus.server.Server
public class Server
Represents background service, for listening binary file transfers or simple text transfers.The server is multithreaded for background working, and for providing good performance.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
boolean |
debug
if true then output will be written in console window. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Server(int port,
JOctopusConsole chatterConsole)
|
|
Server(int port,
java.lang.ThreadGroup group,
JOctopusConsole chatterConsole)
|
|
Server(JOctopusConsole chatterConsole)
|
Method Summary | |
---|---|
void |
addMessageRecieveListener(MessageRecieveListener messageRecieveListener)
sets message recieve listener, its recieveMessage() will be called on recieving client notification. |
java.net.ServerSocket |
getChatServerSocket()
Returns ServerSocket Object |
JOctopusConsole |
getChatterConsole()
|
MessageRecieveListener |
getMessageRecieveListener()
returns messageRecievelistener object. |
int |
getPort()
returns port at which the server is bind and listening for client. |
java.net.Socket |
getRecievedClientSocket()
returns Socket Object that have been recieved, after notification. |
java.nio.channels.SocketChannel |
getRecievedClientSocketChannel()
Returns SocketChannelObject that have been recieved while listening to the port. |
java.lang.String |
getServerName()
returns name of server |
java.nio.channels.ServerSocketChannel |
getServerSocketChannel()
Returns ServerSocketChannel Object that has been listening for client. |
protected void |
instantiateServer()
Instantiates server running for recieving txt messages, else instantiates server socket channel object when server is running for recieving files i.e for File Transfer |
boolean |
isFailToRun()
returns true if some error has occurred in server else false. |
boolean |
isStarted()
|
void |
run()
|
void |
setPort(int port)
Sets port.This method should be called before StartServer() |
protected void |
setRecievedClientSocket(java.net.Socket recievedClientSocket)
sets recieved client socket. |
void |
setServerName(java.lang.String serverName)
Sets server name. |
void |
startServer()
starts server. |
void |
stopService()
Stops the service. |
void |
writeOut(java.lang.String message)
writes output to JOctopusConsole window |
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 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public boolean debug
Constructor Detail |
---|
public Server(JOctopusConsole chatterConsole)
chatterConsole
- public Server(int port, JOctopusConsole chatterConsole)
port
- chatterConsole
- public Server(int port, java.lang.ThreadGroup group, JOctopusConsole chatterConsole)
port
- group
- chatterConsole
- Method Detail |
---|
public JOctopusConsole getChatterConsole()
public boolean isFailToRun()
public java.nio.channels.SocketChannel getRecievedClientSocketChannel()
protected void setRecievedClientSocket(java.net.Socket recievedClientSocket)
recievedClientSocket
- public java.nio.channels.ServerSocketChannel getServerSocketChannel()
public java.net.ServerSocket getChatServerSocket()
public java.lang.String getServerName()
public void setServerName(java.lang.String serverName)
serverName
- public int getPort()
public void setPort(int port)
port
- public java.net.Socket getRecievedClientSocket()
public MessageRecieveListener getMessageRecieveListener()
public void addMessageRecieveListener(MessageRecieveListener messageRecieveListener)
messageRecieveListener
- public void stopService() throws java.io.IOException
java.io.IOException
public boolean isStarted()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
protected void instantiateServer() throws java.net.BindException
java.net.BindException
public void writeOut(java.lang.String message)
message
- public void startServer() throws java.net.BindException
java.net.BindException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |