Exemplo n.º 1
0
    public SessionListener(Session session) {
      m_session = session;

      System.out.println(
          "PubClient: connected "
              + session.getLocalAddress()
              + " -> "
              + session.getRemoteAddress());

      final ByteBuffer buf = ByteBuffer.allocateDirect(5);
      buf.putInt(5);
      buf.put((byte) 0);
      buf.position(0);
      session.sendData(buf);
    }
Exemplo n.º 2
0
    public void run() {
      final ByteBuffer buf = ByteBuffer.allocateDirect(m_messageLength);
      buf.putInt(m_messageLength);
      buf.putInt(m_messages);
      for (int idx = 8; idx < m_messageLength; idx++) buf.put((byte) idx);
      buf.position(0);

      m_startTime = System.nanoTime();
      for (int idx = 0; idx < m_messages; idx++) m_session.sendData(buf);
      final long endTime = System.nanoTime();

      // m_session.closeConnection();

      System.out.println(
          "PubClient: sent "
              + m_messages
              + " messages at "
              + Util.formatDelay(m_startTime, endTime));
    }