Package org.hcjf.io.net
Class NetServer<S extends NetSession,D>
- java.lang.Object
-
- org.hcjf.io.net.NetServiceConsumer<S,D>
-
- org.hcjf.io.net.NetServer<S,D>
-
- All Implemented Interfaces:
ServiceConsumer
- Direct Known Subclasses:
HttpServer,MessagesServer
public abstract class NetServer<S extends NetSession,D> extends NetServiceConsumer<S,D>
This class is a kind of net consumer that represent a server for the ip connections.- Author:
- javaito
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hcjf.io.net.NetServiceConsumer
NetServiceConsumer.DecoupledAction
-
-
Constructor Summary
Constructors Constructor Description NetServer(java.lang.Integer port, NetService.TransportLayerProtocol protocol, boolean multiSession, boolean disconnectAndRemove)
-
Method Summary
Modifier and Type Method Description abstract ScreateSession(NetPackage netPackage)This method must implements the session creation based on the net package that incoming.booleanisCreationTimeoutAvailable()Verify if the specific implementation of net server need to start a connection timeout.booleanisDisconnectAndRemove()This method indicate if the server must destroy de session when the session is disconnected.booleanisMultiSession()This method return a flag to indicate if the server is multisession or notprotected voidonStart()This method should be overwritten to know when the server is startedprotected voidonStop()This method should be overwritten to know when the server is stoppedvoidstart()This method starts the server.voidstop()This method stops the server.-
Methods inherited from class org.hcjf.io.net.NetServiceConsumer
addDecoupledAction, checkSession, decode, decoupleIoAction, destroySession, disconnect, encode, getName, getPort, getProtocol, getService, getShutdownFrame, getShutdownPackage, getSocketOptions, getSSLEngine, getWriteWaitForTimeout, isDecoupledIoAction, onCheckSessionError, onConnect, onConnect, onDisconnect, onDisconnect, onRead, onRead, onWrite, onWrite, setService, setWriteWaitForTimeout, write, write
-
-
-
-
Constructor Detail
-
NetServer
public NetServer(java.lang.Integer port, NetService.TransportLayerProtocol protocol, boolean multiSession, boolean disconnectAndRemove)
-
-
Method Detail
-
createSession
public abstract S createSession(NetPackage netPackage)
This method must implements the session creation based on the net package that incoming.- Parameters:
netPackage- Net package.- Returns:
- Return the session based on the package.
-
isMultiSession
public final boolean isMultiSession()
This method return a flag to indicate if the server is multisession or not- Returns:
- Return true if the server is multisession and false otherwise
-
isDisconnectAndRemove
public final boolean isDisconnectAndRemove()
This method indicate if the server must destroy de session when the session is disconnected.- Returns:
- True to destroy and false otherwise
-
start
public final void start()
This method starts the server.
-
onStart
protected void onStart()
This method should be overwritten to know when the server is started
-
stop
public final void stop()
This method stops the server.
-
onStop
protected void onStop()
This method should be overwritten to know when the server is stopped
-
isCreationTimeoutAvailable
public boolean isCreationTimeoutAvailable()
Verify if the specific implementation of net server need to start a connection timeout.- Returns:
- Connection timeout available.
-
-