Interface IoService

    • Method Detail

      • addListener

        void addListener​(IoServiceListener listener)
        Adds an IoServiceListener that listens any events related with this service.
        Parameters:
        listener - The listener to add
      • removeListener

        void removeListener​(IoServiceListener listener)
        Removed an existing IoServiceListener that listens any events related with this service.
        Parameters:
        listener - The listener to use
      • isDisposing

        boolean isDisposing()
        Returns:
        true if and if only dispose() method has been called. Please note that this method will return true even after all the related resources are released.
      • isDisposed

        boolean isDisposed()
        Returns:
        true if and if only all resources of this processor have been disposed.
      • dispose

        void dispose()
        Releases any resources allocated by this service. Please note that this method might block as long as there are any sessions managed by this service.
      • dispose

        void dispose​(boolean awaitTermination)
        Releases any resources allocated by this service. Please note that this method might block as long as there are any sessions managed by this service. Warning : calling this method from a IoFutureListener with awaitTermination = true will probably lead to a deadlock.
        Parameters:
        awaitTermination - When true this method will block until the underlying ExecutorService is terminated
      • getHandler

        IoHandler getHandler()
        Returns:
        the handler which will handle all connections managed by this service.
      • setHandler

        void setHandler​(IoHandler handler)
        Sets the handler which will handle all connections managed by this service.
        Parameters:
        handler - The IoHandler to use
      • getManagedSessions

        Map<Long,​IoSession> getManagedSessions()
        Returns:
        the map of all sessions which are currently managed by this service. The key of map is the ID of the session. An empty collection if there's no session.
      • getManagedSessionCount

        int getManagedSessionCount()
        Returns:
        the number of all sessions which are currently managed by this service.
      • getSessionConfig

        IoSessionConfig getSessionConfig()
        Returns:
        the default configuration of the new IoSessions created by this service.
      • isActive

        boolean isActive()
        Returns:
        a value of whether or not this service is active
      • getActivationTime

        long getActivationTime()
        Returns:
        the time when this service was activated. It returns the last time when this service was activated if the service is not active now.
      • broadcast

        Set<WriteFuture> broadcast​(Object message)
        Writes the specified message to all the IoSessions managed by this service. This method is a convenience shortcut for IoUtil.broadcast(Object, Collection).
        Parameters:
        message - the message to broadcast
        Returns:
        The set of WriteFuture associated to the message being broadcasted
      • setSessionDataStructureFactory

        void setSessionDataStructureFactory​(IoSessionDataStructureFactory sessionDataStructureFactory)
        Sets the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.
        Parameters:
        sessionDataStructureFactory - The factory to use
      • getScheduledWriteBytes

        int getScheduledWriteBytes()
        Returns:
        The number of bytes scheduled to be written
      • getScheduledWriteMessages

        int getScheduledWriteMessages()
        Returns:
        The number of messages scheduled to be written
      • getStatistics

        IoServiceStatistics getStatistics()
        Returns:
        The statistics object for this service.