public class ExtasysTCPServer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.util.concurrent.ThreadPoolExecutor |
fMyThreadPool |
Constructor and Description |
---|
ExtasysTCPServer(java.lang.String name,
java.lang.String description,
int corePoolSize,
int maximumPoolSize)
Constructs an new Extasys TCP Server.
|
Modifier and Type | Method and Description |
---|---|
TCPListener |
AddListener(java.lang.String name,
java.net.InetAddress ipAddress,
int port,
int maxConnections,
int readBufferSize,
int connectionTimeOut,
int backLog)
Add a new listener to this server.
|
TCPListener |
AddListener(java.lang.String name,
java.net.InetAddress ipAddress,
int port,
int maxConnections,
int readBufferSize,
int connectionTimeOut,
int backLog,
char splitter)
Add new listener with message collector (character splitter).
|
TCPListener |
AddListener(java.lang.String name,
java.net.InetAddress ipAddress,
int port,
int maxConnections,
int readBufferSize,
int connectionTimeOut,
int backLog,
java.lang.String splitter)
Add new listener with message collector (string splitter).
|
void |
Dispose()
Dispose the server.
|
int |
getBytesIn()
Returns the total bytes received from this server.
|
int |
getBytesOut()
Returns the total bytes send from this server.
|
int |
getCurrentConnectionsNumber()
Returns the current connections number of this server.
|
java.lang.String |
getDescription()
Server's description.
|
java.util.ArrayList |
getListeners()
Returns an ArrayList with this server's tcp listeners.
|
java.util.concurrent.ThreadPoolExecutor |
getMyThreadPool()
Returns my Thread Pool.
|
java.lang.String |
getName()
Server's name.
|
void |
OnClientConnect(TCPClientConnection client)
A client connects to this server.
|
void |
OnClientDisconnect(TCPClientConnection client)
A client disconnects from this server.
|
void |
OnDataReceive(TCPClientConnection sender,
DataFrame data)
Server is receiving data from a client connection.
|
void |
RemoveListener(java.lang.String name)
Stop and remove a listener.
|
void |
ReplyToAll(byte[] bytes,
int offset,
int length)
Send data to all connected clients.
|
void |
ReplyToAll(java.lang.String data)
Send data to all connected clients.
|
void |
ReplyToAllExceptSender(byte[] bytes,
int offset,
int length,
TCPClientConnection sender)
Send data to all connected clients excepts sender.
|
void |
ReplyToAllExceptSender(java.lang.String data,
TCPClientConnection sender)
Send data to all connected clients excepts sender.
|
void |
ReplyToSender(byte[] bytes,
int offset,
int length,
TCPClientConnection sender)
Send data to a client.
|
void |
ReplyToSender(java.lang.String data,
TCPClientConnection sender)
Send data to a client.
|
void |
Start()
Start or restart the server.
|
void |
Stop()
Stop the server.
|
public ExtasysTCPServer(java.lang.String name, java.lang.String description, int corePoolSize, int maximumPoolSize)
name
- is the name of the server.description
- is the description of the server.corePoolSize
- is the number of threads to keep in the pool, even if they are idle.maximumPoolSize
- is the maximum number of threads to allow in the pool.public TCPListener AddListener(java.lang.String name, java.net.InetAddress ipAddress, int port, int maxConnections, int readBufferSize, int connectionTimeOut, int backLog)
name
- is the listener's name.ipAddress
- is the listener's IP address.port
- is the listener's tcp port.maxConnections
- is the listener's maximum allowed connections.readBufferSize
- is the read buffer size for each connections in bytes.connectionTimeOut
- is the connections time-out in milliseconds. Set to 0 for no time-out.backLog
- is the number of outstanding connection requests the listener can have.public TCPListener AddListener(java.lang.String name, java.net.InetAddress ipAddress, int port, int maxConnections, int readBufferSize, int connectionTimeOut, int backLog, char splitter)
name
- is the listener's name.ipAddress
- is the listener's IP address.port
- is the listener's tcp port.maxConnections
- is the number of maximum allowed connections.readBufferSize
- is the read buffer size for each connection in bytes.connectionTimeOut
- is the connections time-out in milliseconds. Set to 0 for no time-out.backLog
- is the number of outstanding connection requests the listener can have.splitter
- is the message splitter.public TCPListener AddListener(java.lang.String name, java.net.InetAddress ipAddress, int port, int maxConnections, int readBufferSize, int connectionTimeOut, int backLog, java.lang.String splitter)
name
- is the listener's name.ipAddress
- is the listener's IP address.port
- is the listener's tcp port.maxConnections
- is the number of maximum allowed connections.readBufferSize
- is the read buffer size for each connection in bytes.connectionTimeOut
- is the connections time-out in milliseconds. Set to 0 for no time-out.backLog
- is the number of outstanding connection requests the listener can have.splitter
- is the message splitter.public void RemoveListener(java.lang.String name)
name
- is the listener's name to remove.public void Start() throws java.io.IOException, java.lang.Exception
java.io.IOException
java.lang.Exception
public void Stop()
public void Dispose()
public void OnDataReceive(TCPClientConnection sender, DataFrame data)
sender
- is the client sends the data to this server.data
- is the incoming DataFrame.public void OnClientConnect(TCPClientConnection client)
client
- Client.public void OnClientDisconnect(TCPClientConnection client)
client
- Client.public void ReplyToSender(java.lang.String data, TCPClientConnection sender) throws ClientIsDisconnectedException, OutgoingPacketFailedException
data
- is the string to send.sender
- is the client to send the data.ClientIsDisconnectedException
OutgoingPacketFailedException
public void ReplyToSender(byte[] bytes, int offset, int length, TCPClientConnection sender) throws ClientIsDisconnectedException, OutgoingPacketFailedException
bytes
- is the byte array to be send.offset
- is the position in the data buffer at witch to begin sending.length
- is the number of the bytes to be send.sender
- is the client connection to receive the data.ClientIsDisconnectedException
OutgoingPacketFailedException
public void ReplyToAll(java.lang.String data)
data
- is the string to be send.public void ReplyToAll(byte[] bytes, int offset, int length)
bytes
- is the byte array to be send.offset
- is the position in the data buffer at witch to begin sending.length
- is the number of the bytes to be send.public void ReplyToAllExceptSender(java.lang.String data, TCPClientConnection sender)
data
- is the string to be send.sender
- is the TCP client exception.public void ReplyToAllExceptSender(byte[] bytes, int offset, int length, TCPClientConnection sender)
bytes
- is the byte array to be send.offset
- is the position in the data buffer at witch to begin sending.length
- is the number of the bytes to be send.sender
- is the TCP client exception.public java.lang.String getName()
public java.lang.String getDescription()
public java.util.ArrayList getListeners()
public int getCurrentConnectionsNumber()
public java.util.concurrent.ThreadPoolExecutor getMyThreadPool()
public int getBytesIn()
public int getBytesOut()