Record Class PeerMessage
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.renderer.teavm.PeerMessage
Data structure for messages received from a peer-to-peer connection.
Messages are always in text-based form, even if the underlying protocol
is based on binary messages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMessage type for when a new peer has connected.static final StringMessage type for when a data message has been received.static final StringMessage type for when a previously connected peer has been disconnected, for whatever reason.static final StringMessage type used for connection errors.static final StringMessage type for when this peer connection has completed initialization. -
Constructor Summary
ConstructorsConstructorDescriptionPeerMessage(String type, String value) Creates an instance of aPeerMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.value()Returns the value of thevaluerecord component.
-
Field Details
-
TYPE_INIT
Message type for when this peer connection has completed initialization. The message value is this peer's connection ID, which can be used by other peers to connect.- See Also:
-
TYPE_CONNECT
Message type for when a new peer has connected. The message value is the peer's connection ID.- See Also:
-
TYPE_DISCONNECT
Message type for when a previously connected peer has been disconnected, for whatever reason. The message value is the peer's connection ID.- See Also:
-
TYPE_DATA
Message type for when a data message has been received. The message value is the plain text version of the data that has been received.- See Also:
-
TYPE_ERROR
Message type used for connection errors. The message value provides details on the error.- See Also:
-
-
Constructor Details
-
PeerMessage
Creates an instance of aPeerMessagerecord class.- Parameters:
type- the value for thetyperecord componentvalue- the value for thevaluerecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-