Class NioClient

    • Constructor Summary

      Constructors 
      Constructor Description
      NioClient​(java.net.SocketAddress serverAddress, StreamConnection parser, int connectTimeoutMillis)
      Creates a new client to the given server address using the given StreamConnection to decode the data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void closeConnection()
      Closes the connection to the server, triggering the StreamConnection.connectionClosed() event on the network-handling thread where all callbacks occur.
      com.google.common.util.concurrent.ListenableFuture writeBytes​(byte[] message)
      Writes the given bytes to the remote server.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NioClient

        public NioClient​(java.net.SocketAddress serverAddress,
                         StreamConnection parser,
                         int connectTimeoutMillis)
                  throws java.io.IOException

        Creates a new client to the given server address using the given StreamConnection to decode the data. The given connection MUST be unique to this object. This does not block while waiting for the connection to open, but will call either the StreamConnection.connectionOpened() or StreamConnection.connectionClosed() callback on the created network event processing thread.

        Parameters:
        connectTimeoutMillis - The connect timeout set on the connection (in milliseconds). 0 is interpreted as no timeout.
        Throws:
        java.io.IOException
    • Method Detail

      • writeBytes

        public com.google.common.util.concurrent.ListenableFuture writeBytes​(byte[] message)
                                                                      throws java.io.IOException
        Description copied from interface: MessageWriteTarget
        Writes the given bytes to the remote server. The returned future will complete when all bytes have been written to the OS network buffer.
        Specified by:
        writeBytes in interface MessageWriteTarget
        Throws:
        java.io.IOException