class cMsgDomainServerSelect
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
(package private) java.util.concurrent.atomic.AtomicBoolean |
calledShutdown
Keep track of whether the shutdown method of this object has already been called.
|
(package private) java.util.concurrent.ConcurrentHashMap<cMsgClientData,java.lang.String> |
clients
Set of all clients in this domain server.
|
(package private) java.util.concurrent.ConcurrentHashMap<cMsgClientData,java.lang.String> |
clients2register
Set of all clients waiting to be registered with the selector of this domain server.
|
(package private) static java.lang.String |
domainType
Type of domain this is.
|
(package private) cMsgClientData |
myClientInfo
Object containing information about the client this object is connected to.
|
(package private) java.nio.channels.Selector |
selector
Selector object each client's channel is registered with.
|
Constructor and Description |
---|
cMsgDomainServerSelect(cMsgNameServer nameServer,
int clientsMax,
int debug,
boolean noUdp)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
addClient(cMsgClientData info)
Method to allow another client to send to this domain server.
|
(package private) boolean |
clientIsServer()
Is the single client served by this object is a cMsg server?
|
(package private) void |
deleteClient(cMsgClientData cd)
Method to gracefully remove client from this domain server.
|
(package private) int |
getClientsMax()
Gets the maximum number of clients this object communicates with.
|
int |
getUdpPort()
Getter for the UDP port being used.
|
(package private) int |
numberOfClients() |
void |
run()
This method is a thread which uses select to read messages from clients.
|
(package private) void |
setClientsMax(int clientsMax)
Sets the maximum number of clients this object communicates with.
|
(package private) void |
shutdown()
Method to gracefully shutdown this object's threads and clean things up.
|
(package private) void |
startThreads()
Start reading and writing over the sockets.
|
activeCount, checkAccess, clone, 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
static java.lang.String domainType
cMsgClientData myClientInfo
java.util.concurrent.ConcurrentHashMap<cMsgClientData,java.lang.String> clients
java.util.concurrent.ConcurrentHashMap<cMsgClientData,java.lang.String> clients2register
java.nio.channels.Selector selector
java.util.concurrent.atomic.AtomicBoolean calledShutdown
public cMsgDomainServerSelect(cMsgNameServer nameServer, int clientsMax, int debug, boolean noUdp) throws cMsgException, java.io.IOException
nameServer
- nameServer object which created (is creating) this objectclientsMax
- maximum number of clients serviced by this object at one timedebug
- level of debug output.noUdp
- if true, do not create and listen on a udp socket.cMsgException
- if listening socket could not be opened or a port to listen on could not be foundjava.io.IOException
- if selector cannot be openedint getClientsMax()
void setClientsMax(int clientsMax)
clientsMax
- the maximum number of clients this object communicates withpublic int getUdpPort()
boolean clientIsServer()
void startThreads() throws java.io.IOException
java.io.IOException
- if I/O problemsint numberOfClients()
boolean addClient(cMsgClientData info) throws java.io.IOException
clientsMax
number of clients may use this domain server. Before this method is called, the client
has already created 2 permanent TCP sockets to this server.info
- information on client trying to connect to this domain serverjava.io.IOException
- if socket to client cannot be openedvoid shutdown()
void deleteClient(cMsgClientData cd)
cd
- client data objectpublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread