Package com.tenio.core.network.netty
Class NettyWebSocketServiceImpl
java.lang.Object
com.tenio.common.logger.AbstractLogger
com.tenio.common.logger.SystemLogger
com.tenio.core.manager.AbstractManager
com.tenio.core.network.netty.NettyWebSocketServiceImpl
- All Implemented Interfaces:
NettyWebSocketService
,Service
@ThreadSafe
public final class NettyWebSocketServiceImpl
extends AbstractManager
implements NettyWebSocketService
The implementation for the Netty's websockets services.
-
Field Summary
Fields inherited from class com.tenio.core.manager.AbstractManager
eventManager
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
Retrieves the service's name.void
Initializes a new service.boolean
Determines whether the service is activated.static NettyWebSocketService
newInstance
(EventManager eventManager) Creates a new instance of web socket service.void
setConnectionFilter
(ConnectionFilter connectionFilter) Sets an instance for the connection filter.void
setConsumerWorkerSize
(int workerSize) Sets the number of consumer workers for the WebSocket.void
setDataType
(com.tenio.common.data.DataType dataType) Set the data serialization type.void
Set the service's name.void
setNetworkReaderStatistic
(NetworkReaderStatistic networkReaderStatistic) Sets a network reader statistic instance which takes responsibility recording the receiving data from clients.void
setNetworkWriterStatistic
(NetworkWriterStatistic networkWriterStatistic) Sets a network writer statistic instance which takes responsibility recording the sending data from the network.void
setProducerWorkerSize
(int workerSize) Sets the number of producer workers for the WebSocket.void
setReceiverBufferSize
(int bufferSize) Sets size ofByteBuffer
using for the WebSocket to read binaries data from.void
setSenderBufferSize
(int bufferSize) Sets size ofByteBuffer
using for the WebSocket to write binaries data down.void
setSessionManager
(SessionManager sessionManager) Sets a session manager instance.void
setUsingSsl
(boolean usingSsl) Determines whether the WebSocket is able to use the SSL.void
setWebSocketConfig
(SocketConfiguration socketConfiguration) Declares a socket configurations for the WebSocket.void
shutdown()
Shutdown the service.void
start()
Start the service.void
Writes down (binaries) data to socket/channel in order to send them to client side.Methods inherited from class com.tenio.common.logger.SystemLogger
debug, debugEvent, isDebugEnabled, isTraceEnabled, trace, trace
Methods inherited from class com.tenio.common.logger.AbstractLogger
buildgen, error, error, error, info, info, info, info, info, info, info, info, isErrorEnabled, isInfoEnabled
-
Method Details
-
newInstance
Creates a new instance of web socket service.- Parameters:
eventManager
- the instance ofEventManager
- Returns:
- a new instance of
NettyWebSocketService
-
initialize
public void initialize()Description copied from interface:Service
Initializes a new service.- Specified by:
initialize
in interfaceService
-
start
public void start()Description copied from interface:Service
Start the service. -
shutdown
public void shutdown()Description copied from interface:Service
Shutdown the service. -
getName
Description copied from interface:Service
Retrieves the service's name. -
setName
Description copied from interface:Service
Set the service's name. -
isActivated
public boolean isActivated()Description copied from interface:Service
Determines whether the service is activated.- Specified by:
isActivated
in interfaceService
- Returns:
true
if the service is activated,false
otherwise
-
setSenderBufferSize
public void setSenderBufferSize(int bufferSize) Description copied from interface:NettyWebSocketService
Sets size ofByteBuffer
using for the WebSocket to write binaries data down.- Specified by:
setSenderBufferSize
in interfaceNettyWebSocketService
- Parameters:
bufferSize
- the size ofByteBuffer
(integer
value) for writing binaries data
-
setReceiverBufferSize
public void setReceiverBufferSize(int bufferSize) Description copied from interface:NettyWebSocketService
Sets size ofByteBuffer
using for the WebSocket to read binaries data from.- Specified by:
setReceiverBufferSize
in interfaceNettyWebSocketService
- Parameters:
bufferSize
- the size ofByteBuffer
(integer
value) for reading binaries data
-
setProducerWorkerSize
public void setProducerWorkerSize(int workerSize) Description copied from interface:NettyWebSocketService
Sets the number of producer workers for the WebSocket.- Specified by:
setProducerWorkerSize
in interfaceNettyWebSocketService
- Parameters:
workerSize
- the number (integer
value) of producer workers for the WebSocket
-
setConsumerWorkerSize
public void setConsumerWorkerSize(int workerSize) Description copied from interface:NettyWebSocketService
Sets the number of consumer workers for the WebSocket.- Specified by:
setConsumerWorkerSize
in interfaceNettyWebSocketService
- Parameters:
workerSize
- the number (integer
value) of consumer workers for the WebSocket
-
setConnectionFilter
Description copied from interface:NettyWebSocketService
Sets an instance for the connection filter.- Specified by:
setConnectionFilter
in interfaceNettyWebSocketService
- Parameters:
connectionFilter
- an instance ofConnectionFilter
-
setDataType
public void setDataType(com.tenio.common.data.DataType dataType) Description copied from interface:NettyWebSocketService
Set the data serialization type.- Specified by:
setDataType
in interfaceNettyWebSocketService
- Parameters:
dataType
- theDataType
value
-
setSessionManager
Description copied from interface:NettyWebSocketService
Sets a session manager instance.- Specified by:
setSessionManager
in interfaceNettyWebSocketService
- Parameters:
sessionManager
- aSessionManager
instance
-
setNetworkReaderStatistic
Description copied from interface:NettyWebSocketService
Sets a network reader statistic instance which takes responsibility recording the receiving data from clients.- Specified by:
setNetworkReaderStatistic
in interfaceNettyWebSocketService
- Parameters:
networkReaderStatistic
- aNetworkReaderStatistic
instance
-
setNetworkWriterStatistic
Description copied from interface:NettyWebSocketService
Sets a network writer statistic instance which takes responsibility recording the sending data from the network.- Specified by:
setNetworkWriterStatistic
in interfaceNettyWebSocketService
- Parameters:
networkWriterStatistic
- aNetworkWriterStatistic
instance
-
setWebSocketConfig
Description copied from interface:NettyWebSocketService
Declares a socket configurations for the WebSocket.- Specified by:
setWebSocketConfig
in interfaceNettyWebSocketService
- Parameters:
socketConfiguration
- a instance ofSocketConfiguration
-
setUsingSsl
public void setUsingSsl(boolean usingSsl) Description copied from interface:NettyWebSocketService
Determines whether the WebSocket is able to use the SSL.- Specified by:
setUsingSsl
in interfaceNettyWebSocketService
- Parameters:
usingSsl
- sets totrue
in case of using SSL, otherwise returnsfalse
-
write
Description copied from interface:NettyWebSocketService
Writes down (binaries) data to socket/channel in order to send them to client side.- Specified by:
write
in interfaceNettyWebSocketService
- Parameters:
packet
- an instance ofPacket
using to carry conveying information
-