
public abstract class AbstractSocketServerXSocket extends AbstractSocketServer implements org.xsocket.connection.IConnectHandler, org.xsocket.connection.IDisconnectHandler, org.xsocket.connection.IDataHandler, org.xsocket.connection.IIdleTimeoutHandler, org.xsocket.connection.IConnectionTimeoutHandler, ISocketServerConnectionListener
| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
activateConnectionLogging
True to allow xSocket connection to log.
|
protected org.xsocket.connection.IServer |
srv
xSocket server.
|
protected TransferRateCalculator |
transferRate
Calculates transfer rates.
|
DEFAULT_TCP_BUFFERS_SIZE, listenPort, nWorkersCPUmultiplier, nWorkersIO, protocolDecoderFactory, tcpBufferSizeIn, tcpBufferSizeOut, workerPool| Constructor and Description |
|---|
AbstractSocketServerXSocket(ISocketServerProtocolDecoderFactory protocolFactory,
int listenPort)
Constructor.
|
AbstractSocketServerXSocket(ISocketServerProtocolDecoderFactory protocolFactory,
int listenPort,
SSLContext sslContext,
int idleTimeout,
int connectionTimeout)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the server.
|
org.xsocket.connection.IServer |
getServerXSocket()
Returns the xSocket server class.
|
long |
getTotalReadBytes()
Returns the total number of bytes read.
|
long |
getTotalSentBytes()
Retuns the total number of bytes sent.
|
float |
getTransferRateIn()
Incoming data transfer rate in bytes/second.
|
float |
getTransferRateOut()
Outgoing data transfer rate in bytes/second.
|
boolean |
onConnect(org.xsocket.connection.INonBlockingConnection connection)
Socket connected.
|
boolean |
onConnectionTimeout(org.xsocket.connection.INonBlockingConnection connection)
Method called when a connection timeout is reached.
|
boolean |
onData(org.xsocket.connection.INonBlockingConnection connection)
New data available on xSocket connection.
|
boolean |
onDisconnect(org.xsocket.connection.INonBlockingConnection connection)
Disconnect event.
|
boolean |
onIdleTimeout(org.xsocket.connection.INonBlockingConnection connection)
Idle time out event.
|
void |
packetSent(ISocketServerConnection connection,
int size)
Data sent notification.
|
void |
run()
Stars the server in the current thread.
|
static void |
setActivateConnectionLogging(boolean activateConnectionLogging)
Sets the xSocket connection log.
|
void |
setIP(String ip)
Sets the IP to bind the port.
|
void |
start()
Starts the server in a different thread.
|
setPortclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpacketArrived, socketConnected, socketDisconnected, socketExceptionprotected TransferRateCalculator transferRate
protected static boolean activateConnectionLogging
protected org.xsocket.connection.IServer srv
public AbstractSocketServerXSocket(ISocketServerProtocolDecoderFactory protocolFactory, int listenPort)
protocolFactory - protocol decoder factory to be used by the serverlistenPort - port to be used by the server to accept incoming connectionspublic AbstractSocketServerXSocket(ISocketServerProtocolDecoderFactory protocolFactory, int listenPort, SSLContext sslContext, int idleTimeout, int connectionTimeout)
protocolFactory - protocol decoder factory to be used by the server.listenPort - port to be used by the server to accept incoming connections.sslContext - SSLContext.idleTimeout - milliseconds to receive some data, connection will be closed
if no data is received. 0 to disable timeout.connectionTimeout - milliseconds to close the connection after being established.
0 to disable timeout.public static void setActivateConnectionLogging(boolean activateConnectionLogging)
activateConnectionLogging - true to allow xSocket connection to logpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ISocketServerIOException - error closing the socket server.public org.xsocket.connection.IServer getServerXSocket()
public long getTotalReadBytes()
getTotalReadBytes in interface ISocketServerpublic long getTotalSentBytes()
getTotalSentBytes in interface ISocketServerpublic float getTransferRateIn()
getTransferRateIn in interface ISocketServerpublic float getTransferRateOut()
getTransferRateOut in interface ISocketServerpublic boolean onConnect(org.xsocket.connection.INonBlockingConnection connection)
throws IOException
onConnect in interface org.xsocket.connection.IConnectHandlerconnection - new xSocket connection openedIOException - error handling new connectionpublic boolean onConnectionTimeout(org.xsocket.connection.INonBlockingConnection connection)
throws IOException
onConnectionTimeout in interface org.xsocket.connection.IConnectionTimeoutHandlerconnection - the connectionIOException - error handling connection timeoutpublic boolean onData(org.xsocket.connection.INonBlockingConnection connection)
throws IOException
onData in interface org.xsocket.connection.IDataHandlerconnection - the connectionIOException - error while processing incoming data.public boolean onDisconnect(org.xsocket.connection.INonBlockingConnection connection)
throws IOException
onDisconnect in interface org.xsocket.connection.IDisconnectHandlerconnection - the disconnected connectionIOException - error handling disconnect eventpublic boolean onIdleTimeout(org.xsocket.connection.INonBlockingConnection connection)
throws IOException
onIdleTimeout in interface org.xsocket.connection.IIdleTimeoutHandlerconnection - the idle connectionIOException - error handling idle timeoutpublic void packetSent(ISocketServerConnection connection, int size)
packetSent in interface ISocketServerConnectionListenerconnection - connectionsize - the size of the data sentpublic void run()
throws IOException
run in interface ISocketServerIOException - error starting the serveres.tsbsoluciones.socketServer.ISocketServer#run()public void setIP(String ip)
setIP in interface ISocketServerip - the IP to be used to bind the portpublic void start()
throws IOException
start in interface ISocketServerIOException - error starting the serverCopyright © 2018 universAAL Consortium. All rights reserved.