Module unixsocketconnection
Class UnixDomainSocketRPCConnection
java.lang.Object
com.ensarsarajcic.neovim.java.unix.socket.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
-
Constructor Summary
Constructors Constructor Description UnixDomainSocketRPCConnection(java.io.File path)
Creates a newUnixDomainSocketRPCConnection
connected to the file on given path It uses input/output stream provided byUnixDomainSocket
created for given file -
Method Summary
Modifier and Type Method Description void
close()
Closes underlyingUnixDomainSocket
Communication is no longer possible after this calljava.io.InputStream
getIncomingStream()
Gets theInputStream
of the underlyingUnixDomainSocket
java.io.OutputStream
getOutgoingStream()
Gets theOutputStream
of the underlyingUnixDomainSocket
java.lang.String
toString()
-
Constructor Details
-
UnixDomainSocketRPCConnection
public UnixDomainSocketRPCConnection(java.io.File path)Creates a newUnixDomainSocketRPCConnection
connected to the file on given path It uses input/output stream provided byUnixDomainSocket
created for given file- Parameters:
path
- file to use as unix domain socket- Throws:
java.lang.NullPointerException
- if path is nulljava.lang.RuntimeException
- if socket can't be open for given path
-
-
Method Details
-
getIncomingStream
public java.io.InputStream getIncomingStream()Gets theInputStream
of the underlyingUnixDomainSocket
- Specified by:
getIncomingStream
in interfacecom.ensarsarajcic.neovim.java.corerpc.client.RPCConnection
- Returns:
InputStream
of the underlyingUnixDomainSocket
-
getOutgoingStream
public java.io.OutputStream getOutgoingStream()Gets theOutputStream
of the underlyingUnixDomainSocket
- Specified by:
getOutgoingStream
in interfacecom.ensarsarajcic.neovim.java.corerpc.client.RPCConnection
- Returns:
OutputStream
of the underlyingUnixDomainSocket
-
close
public void close() throws java.io.IOExceptionCloses underlyingUnixDomainSocket
Communication is no longer possible after this call- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- if underlyingUnixDomainSocket
throws exception
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-