private void dispatch()
	{
		try
		{
			if (selector.select(NetWorkConstants.DEFAULT_NETWORK_TIME_OUT) <= 0)
			{
				return;
			}
		}
		catch (IOException e)
		{
			log.error(e);
		}

		Iterator<SelectionKey> iterator = selector.selectedKeys().iterator();

		while (iterator.hasNext())
		{
			SelectionKey key = (SelectionKey) iterator.next();
			iterator.remove();
			try
			{
				if (!key.isValid())
				{
					key.cancel();
					continue;
				}

				if (key.isAcceptable())
				{
					onAccept(key);
				}
				else if (key.isReadable())
				{
					onRead(key);
				}
				else if (key.isWritable())
				{
					onWrite(key);
				}
			}
			catch (Exception e)
			{
				e.printStackTrace();
				log.error(e);
				Session session = (Session) key.attachment();
				//
				sessionManager.freeSession(session);
			}
		}

	}