Class UnixDomainSocketRPCConnection

  • All Implemented Interfaces:
    com.ensarsarajcic.neovim.java.corerpc.client.RPCConnection, java.io.Closeable, java.lang.AutoCloseable

    public final class UnixDomainSocketRPCConnection
    extends java.lang.Object
    implements com.ensarsarajcic.neovim.java.corerpc.client.RPCConnection
    Simple implementation of RPCConnection based on a unix domain socket

    This allows connection and communication via unix domain socket/windows named pipe It is a very simple implementation and it just passes down calls to underlying UnixDomainSocket

    Example:

         
         File socket = new File("/var/nvim/random");
    
         RPCConnection fileConnection = new UnixDomainSocketRPCConnection(socket);
    
         // It can now be used for communication
         rpcStreamer.attach(fileConnection);
         rpcStreamer.sent(message); // send a message to unix domain socket located on /var/nvim/random
         
     
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes underlying UnixDomainSocket Communication is no longer possible after this call
      java.io.InputStream getIncomingStream()
      Gets the InputStream of the underlying UnixDomainSocket
      java.io.OutputStream getOutgoingStream()
      Gets the OutputStream of the underlying UnixDomainSocket
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • UnixDomainSocketRPCConnection

        public UnixDomainSocketRPCConnection​(java.io.File path)
        Creates a new UnixDomainSocketRPCConnection connected to the file on given path It uses input/output stream provided by UnixDomainSocket created for given file
        Parameters:
        path - file to use as unix domain socket
        Throws:
        java.lang.NullPointerException - if path is null
        java.lang.RuntimeException - if socket can't be open for given path
    • Method Detail

      • getIncomingStream

        public java.io.InputStream getIncomingStream()
        Gets the InputStream of the underlying UnixDomainSocket
        Specified by:
        getIncomingStream in interface com.ensarsarajcic.neovim.java.corerpc.client.RPCConnection
        Returns:
        InputStream of the underlying UnixDomainSocket
      • getOutgoingStream

        public java.io.OutputStream getOutgoingStream()
        Gets the OutputStream of the underlying UnixDomainSocket
        Specified by:
        getOutgoingStream in interface com.ensarsarajcic.neovim.java.corerpc.client.RPCConnection
        Returns:
        OutputStream of the underlying UnixDomainSocket
      • close

        public void close()
                   throws java.io.IOException
        Closes underlying UnixDomainSocket Communication is no longer possible after this call
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - if underlying UnixDomainSocket throws exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object