org.apache.ignite.internal.processors.rest.protocols.tcp

## Class GridTcpRestNioListener

- java.lang.Object
- - org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter<GridClientMessage>
  - - org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestNioListener

All Implemented Interfaces:
  EventListener, GridNioServerListener<GridClientMessage>

    public class GridTcpRestNioListener
    extends GridNioServerListenerAdapter<GridClientMessage>

Listener for nio server that handles incoming tcp rest packets.

### Constructor Summary

Constructors
Constructor and Description
`GridTcpRestNioListener(IgniteLogger log, GridTcpRestProtocol proto, GridRestProtocolHandler hnd, GridKernalContext ctx)` Creates listener which will convert incoming tcp packets to rest requests and forward them to a given rest handler.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `onConnected(GridNioSession ses)` This method is called whenever a new client is connected and session is created.
`void` `onDisconnected(GridNioSession ses, Exception e)` This method is called whenever client is disconnected due to correct connection close or due to `IOException` during network operations.
`void` `onMessage(GridNioSession ses, GridClientMessage msg)` This method is called whenever a `GridNioParser` returns non-null value.
`void` `onSessionIdleTimeout(GridNioSession ses)` Closes the session by timeout (i.e. inactivity within the configured period of time).

### Methods inherited from class org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter

`onFailure, onMessageSent, onSessionWriteTimeout`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GridTcpRestNioListener

    public GridTcpRestNioListener(IgniteLogger log,
                                  GridTcpRestProtocol proto,
                                  GridRestProtocolHandler hnd,
                                  GridKernalContext ctx)

Creates listener which will convert incoming tcp packets to rest requests and forward them to a given rest handler.

Parameters:
  `log` - Logger to use.
  `proto` - Protocol.
  `hnd` - Rest handler.
  `ctx` - Context.

### Method Detail

#### onConnected

    public void onConnected(GridNioSession ses)

This method is called whenever a new client is connected and session is created.

Parameters:
  `ses` - Newly created session for remote client.

#### onDisconnected

    public void onDisconnected(GridNioSession ses,
                               @Nullable
                               Exception e)

This method is called whenever client is disconnected due to correct connection close or due to `IOException` during network operations.

Parameters:
  `ses` - Closed session.
  `e` - Exception occurred, if any.

#### onMessage

    public void onMessage(GridNioSession ses,
                          GridClientMessage msg)

This method is called whenever a `GridNioParser` returns non-null value.

Parameters:
  `ses` - Session on which message was received.
  `msg` - Parsed message.

#### onSessionIdleTimeout

    public void onSessionIdleTimeout(GridNioSession ses)

Closes the session by timeout (i.e. inactivity within the configured period of time).

Specified by:
  `onSessionIdleTimeout` in interface `GridNioServerListener<GridClientMessage>`
Overrides:
  `onSessionIdleTimeout` in class `GridNioServerListenerAdapter<GridClientMessage>`
Parameters:
  `ses` - Session, that was inactive.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.5
Release Date | : June 4 2019