public final class FCPPluginMessage
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FCPPluginMessage.ClientPermissions |
Modifier and Type | Field and Description |
---|---|
Bucket |
data
Part 2 of the actual message: Non-human readable, large size bulk data.
Can be null if no large amount of data is to be transfered. |
java.lang.String |
errorCode
For reply messages with
success == false, may contain an alpha-numeric String
which identifies a reason for the failure in a standardized representation which software
can parse easily. |
java.lang.String |
errorMessage
For reply messages with
errorCode != null, may contain a String which describes
the problem in a human-readable, user-friendly manner. |
java.lang.String |
identifier
The unique identifier of the message.
Can be used by server and client to track the progress of messages. This especially applies to FCPPluginConnection.sendSynchronous(SendDirection,
FCPPluginMessage, long) which will wait for a reply with the same identifier as the
original message until it returns.For reply messages, this shall be the same as the identifier of the message to which this is a reply. For non-reply message, this shall be a sufficiently random String to prevent
collisions with any previous message identifiers. |
SimpleFieldSet |
params
Part 1 of the actual message: Human-readable parameters.
|
FCPPluginMessage.ClientPermissions |
permissions
The permissions of the client which sent the messages.
|
java.lang.Boolean |
success
For messages which are a reply to another message, this is always non-null.
|
Modifier and Type | Method and Description |
---|---|
static FCPPluginMessage |
construct()
Same as
construct(SimpleFieldSet, Bucket) with the missing parameters being:SimpleFieldSet params = new SimpleFieldSet(shortLived = true); ATTENTION: Messages constructed with this constructor here are not reply messages. If you are replying to a message, notably when returning a message in the message handler interface implementation, you must use constructReplyMessage(FCPPluginMessage,
SimpleFieldSet, Bucket, boolean, String, String) (or one of its shortcuts) instead. |
static FCPPluginMessage |
construct(SimpleFieldSet params,
Bucket data)
For being used by server or client to construct outgoing messages.
Those can then be passed to the send functions of FCPPluginConnection or returned in
the message handlers of FredPluginFCPMessageHandler .ATTENTION: Messages constructed with this constructor here are not reply messages. If you are replying to a message, notably when returning a message in the message handler interface implementation, you must use constructReplyMessage(FCPPluginMessage,
SimpleFieldSet, Bucket, boolean, String, String) (or one of its shortcuts) instead.See the JavaDoc of the member variables with the same name as the parameters for an explanation of the parameters. There is a shortcut to this constructor for typical choice of parameters: construct() . |
static FCPPluginMessage |
constructErrorReply(FCPPluginMessage originalMessage,
java.lang.String errorCode,
java.lang.String errorMessage)
Same as
constructReplyMessage(FCPPluginMessage, SimpleFieldSet, Bucket, boolean,
String, String) with the missing parameters being:
SimpleFieldSet params = new SimpleFieldSet(shortLived = true); |
static FCPPluginMessage |
constructReplyMessage(FCPPluginMessage originalMessage,
SimpleFieldSet params,
Bucket data,
boolean success,
java.lang.String errorCode,
java.lang.String errorMessage)
For being used by server or client to construct outgoing messages which are a reply to an
original message.
Those then can be returned from the message handler FredPluginFCPMessageHandler.handlePluginFCPMessage(FCPPluginConnection,
FCPPluginMessage) .See the JavaDoc of the member variables with the same name as the parameters for an explanation of the parameters. There are shortcuts to this constructor for typical choice of parameters: constructSuccessReply(FCPPluginMessage) .constructErrorReply(FCPPluginMessage, String, String) . |
static FCPPluginMessage |
constructSuccessReply(FCPPluginMessage originalMessage)
Same as
constructReplyMessage(FCPPluginMessage, SimpleFieldSet, Bucket, boolean,
String, String) with the missing parameters being:
SimpleFieldSet params = new SimpleFieldSet(shortLived = true); |
boolean |
isReplyMessage() |
java.lang.String |
toString() |
public final FCPPluginMessage.ClientPermissions permissions
FCPPluginConnection
before delivery of the message. Thus, you
can pass null for this in all constructors.public final java.lang.String identifier
FCPPluginConnection.sendSynchronous(SendDirection,
FCPPluginMessage, long)
which will wait for a reply with the same identifier as the
original message until it returns.String
to prevent
collisions with any previous message identifiers. The default is a random UUID
, and
alternate implementations are recommended to use a random UUID
as well.public final SimpleFieldSet params
public final Bucket data
public final java.lang.Boolean success
isReplyMessage()
- a reply message has success != null, a non-reply message has
success == null.public final java.lang.String errorCode
success
== false, may contain an alpha-numeric String
which identifies a reason for the failure in a standardized representation which software
can parse easily. May also be null in that case, but please try to not do that.success
== null or true, this must be null.public final java.lang.String errorMessage
errorCode
!= null, may contain a String which describes
the problem in a human-readable, user-friendly manner. May also be null in that case, but
please try to not do that.errorCode
== null, this must be null.errorCode
.
For Exceptions which you do not expect, Throwable.toString()
will return a
sufficient errorMessage (containing the name of the Exception and the localized error
message, or non-localized if there is no translation).errorCode
is non-null instead of just
if success
== false to ensure that a developer-friendly error signaling is
implemented: errorCode is designed to be easy to parse, errorMessage is designed
to be human readable and thus cannot be parsed. Therefore, the errorCode field should be
more mandatory than this field.)public boolean isReplyMessage()
public static FCPPluginMessage construct(SimpleFieldSet params, Bucket data)
FCPPluginConnection
or returned in
the message handlers of FredPluginFCPMessageHandler
.constructReplyMessage(FCPPluginMessage,
SimpleFieldSet, Bucket, boolean, String, String)
(or one of its shortcuts) instead.construct()
.public static FCPPluginMessage construct()
construct(SimpleFieldSet, Bucket)
with the missing parameters being:SimpleFieldSet params = new SimpleFieldSet(shortLived = true);
Bucket data = null;
constructReplyMessage(FCPPluginMessage,
SimpleFieldSet, Bucket, boolean, String, String)
(or one of its shortcuts) instead.public static FCPPluginMessage constructReplyMessage(FCPPluginMessage originalMessage, SimpleFieldSet params, Bucket data, boolean success, java.lang.String errorCode, java.lang.String errorMessage)
FredPluginFCPMessageHandler.handlePluginFCPMessage(FCPPluginConnection,
FCPPluginMessage)
.constructSuccessReply(FCPPluginMessage)
.constructErrorReply(FCPPluginMessage, String, String)
.java.lang.IllegalStateException
- If the original message was a reply message already.public static FCPPluginMessage constructSuccessReply(FCPPluginMessage originalMessage)
constructReplyMessage(FCPPluginMessage, SimpleFieldSet, Bucket, boolean,
String, String)
with the missing parameters being:
SimpleFieldSet params = new SimpleFieldSet(shortLived = true);
Bucket data = null;
boolean success = true;
errorCode = null;
errorMessage = null;
public static FCPPluginMessage constructErrorReply(FCPPluginMessage originalMessage, java.lang.String errorCode, java.lang.String errorMessage)
constructReplyMessage(FCPPluginMessage, SimpleFieldSet, Bucket, boolean,
String, String)
with the missing parameters being:
SimpleFieldSet params = new SimpleFieldSet(shortLived = true);
Bucket data = null;
boolean success = false;
public java.lang.String toString()
toString
in class java.lang.Object