Verified Owner
Top Fields Constructors Methods
org.jabref.logic.remote

public Class Protocol

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.io.IOException, .InputStream, .ObjectInputStream, .ObjectOutputStream, java.net.Socket, .URLDecoder, .URLEncoder, java.nio.charset.StandardCharsets, javafx.util.Pair, org.slf4j.Logger, .LoggerFactory

Implementation Note

The first byte of every message identifies its type as a RemoteMessage. Every message is terminated with '\0'.

Field Summary

Modifier and TypeField and Description
public static final String
private final ObjectInputStream
private static final Logger
private final ObjectOutputStream
private final Socket

Constructor Summary

AccessConstructor and Description
public
Protocol(Socket socket)

public
Protocol(Socket
the connection to communicate over; only its output stream is used
socket
,
InputStream
the stream to read requests from — a wrapper around the socket's input stream that supports non-destructive probing, restored to the start of the request
inputStream
)

Creates a protocol using a previously inspected input stream.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public Pair<RemoteMessage, Object>
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IDENTIFIERback to summary
public static final String IDENTIFIER
inback to summary
private final ObjectInputStream in
LOGGERback to summary
private static final Logger LOGGER
outback to summary
private final ObjectOutputStream out
socketback to summary
private final Socket socket

Constructor Detail

Protocolback to summary
public Protocol(Socket socket) throws IOException
Protocolback to summary
public Protocol(Socket socket, InputStream inputStream) throws IOException

Creates a protocol using a previously inspected input stream.

The remote listener uses this overload after checking whether the connection is a plain-text health check rather than a serialized remote-operation request.

Parameters
socket:Socket

the connection to communicate over; only its output stream is used

inputStream:InputStream

the stream to read requests from — a wrapper around the socket's input stream that supports non-destructive probing, restored to the start of the request

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
receiveMessageback to summary
public Pair<RemoteMessage, Object> receiveMessage() throws IOException
sendMessageback to summary
public void sendMessage(RemoteMessage type) throws IOException
sendMessageback to summary
public void sendMessage(RemoteMessage type, Object argument) throws IOException