org.apache.ignite.internal.client.router.impl

## Class GridTcpRouterNioListenerAdapter

- java.lang.Object
- - org.apache.ignite.internal.client.router.impl.GridTcpRouterNioListenerAdapter

All Implemented Interfaces:
  GridNioServerListener<GridClientMessage>

    public abstract class GridTcpRouterNioListenerAdapter
    extends Object
    implements GridNioServerListener<GridClientMessage>

Nio listener for the router. Extracts necessary meta information from messages and delegates their delivery to underlying client.

### Field Summary

Fields
`protected Map<Byte,GridClientMarshaller>` `marshMap` Marshallers map.

### Constructor Summary

Constructors
Constructor and Description
`GridTcpRouterNioListenerAdapter(IgniteLogger log, GridRouterClientImpl client)`

### Method Summary

Methods
`protected abstract void` `init()`
`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)` Called when session did not receive any activity within timeout interval.
`void` `onSessionWriteTimeout(GridNioSession ses)` Called when session has non-empty write queue and server did not send any data within timeout interval.

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

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

### Field Detail

#### marshMap

    protected final Map<Byte,GridClientMarshaller> marshMap

Marshallers map.

### Constructor Detail

#### GridTcpRouterNioListenerAdapter

    public GridTcpRouterNioListenerAdapter(IgniteLogger log,
                                   GridRouterClientImpl client)

Parameters:
  `log` - Logger.
  `client` - Client for grid access.

### Method Detail

#### init

    protected abstract void init()

#### onConnected

    public void onConnected(GridNioSession ses)

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

Specified by:
  `onConnected` in interface `GridNioServerListener<GridClientMessage>`
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.

Specified by:
  `onDisconnected` in interface `GridNioServerListener<GridClientMessage>`
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.

Specified by:
  `onMessage` in interface `GridNioServerListener<GridClientMessage>`
Parameters:
  `ses` - Session on which message was received.
  `msg` - Parsed message.

#### onSessionWriteTimeout

    public void onSessionWriteTimeout(GridNioSession ses)

Called when session has non-empty write queue and server did not send any data within timeout interval.

Specified by:
  `onSessionWriteTimeout` in interface `GridNioServerListener<GridClientMessage>`
Parameters:
  `ses` - Session that has timed out writes.

#### onSessionIdleTimeout

    public void onSessionIdleTimeout(GridNioSession ses)

Called when session did not receive any activity within timeout interval.

Specified by:
  `onSessionIdleTimeout` in interface `GridNioServerListener<GridClientMessage>`
Parameters:
  `ses` - Session that is idle.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0-b1
Release Date | : December 1 2015