-
- All Superinterfaces:
- RemoteEndpoint
- Enclosing interface:
- RemoteEndpoint
public static interface RemoteEndpoint.Basic extends RemoteEndpoint
This representation of the peer of a web socket conversation has the ability to send messages synchronously. The point of completion of the send is defined when all the supplied data has been written to the underlying connection. The methods for sending messages on the RemoteEndpoint.Basic block until this point of completion is reached, except forgetSendStream
andgetSendWriter
which present traditional blocking I/O streams to write messages.If the websocket connection underlying this RemoteEndpoint is busy sending a message when a call is made to send another one, for example if two threads attempt to call a send method concurrently, or if a developer attempts to send a new message while in the middle of sending an existing one, the send method called while the connection is already busy may throw an
IllegalStateException
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.websocket.RemoteEndpoint
RemoteEndpoint.Async, RemoteEndpoint.Basic
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description OutputStream
getSendStream()
Opens an output stream on which a binary message may be sent.Writer
getSendWriter()
Opens an character stream on which a text message may be sent.void
sendBinary(ByteBuffer data)
Send a binary message, returning when all of the message has been transmitted.void
sendBinary(ByteBuffer partialByte, boolean isLast)
Send a binary message in parts, blocking until all of the message has been transmitted.void
sendObject(Object data)
Sends a custom developer object, blocking until it has been transmitted.void
sendText(String text)
Send a text message, blocking until all of the message has been transmitted.void
sendText(String partialMessage, boolean isLast)
Send a text message in parts, blocking until all of the message has been transmitted.-
Methods inherited from interface javax.websocket.RemoteEndpoint
flushBatch, getBatchingAllowed, sendPing, sendPong, setBatchingAllowed
-
-
-
-
Method Detail
-
sendText
void sendText(String text) throws IOException
Send a text message, blocking until all of the message has been transmitted.- Parameters:
text
- the message to be sent.- Throws:
IOException
- if there is a problem delivering the message.IllegalArgumentException
- if the text isnull
.
-
sendBinary
void sendBinary(ByteBuffer data) throws IOException
Send a binary message, returning when all of the message has been transmitted.- Parameters:
data
- the message to be sent.- Throws:
IOException
- if there is a problem delivering the message.IllegalArgumentException
- if the data isnull
.
-
sendText
void sendText(String partialMessage, boolean isLast) throws IOException
Send a text message in parts, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final parts of the message are sent with isLast set to false. The final part must be sent with isLast set to true.- Parameters:
partialMessage
- the parts of the message being sent.isLast
- Whether the partial message being sent is the last part of the message.- Throws:
IOException
- if there is a problem delivering the message fragment.IllegalArgumentException
- if the partialMessage isnull
.
-
sendBinary
void sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException
Send a binary message in parts, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final parts are sent with isLast set to false. The final piece must be sent with isLast set to true.- Parameters:
partialByte
- the part of the message being sent.isLast
- Whether the partial message being sent is the last part of the message.- Throws:
IOException
- if there is a problem delivering the partial message.IllegalArgumentException
- if the partialByte isnull
.
-
getSendStream
OutputStream getSendStream() throws IOException
Opens an output stream on which a binary message may be sent. The developer must close the output stream in order to indicate that the complete message has been placed into the output stream.- Returns:
- the output stream to which the message will be written.
- Throws:
IOException
- if there is a problem obtaining the OutputStream to write the binary message.
-
getSendWriter
Writer getSendWriter() throws IOException
Opens an character stream on which a text message may be sent. The developer must close the writer in order to indicate that the complete message has been placed into the character stream.- Returns:
- the writer to which the message will be written.
- Throws:
IOException
- if there is a problem obtaining the Writer to write the text message.
-
sendObject
void sendObject(Object data) throws IOException, EncodeException
Sends a custom developer object, blocking until it has been transmitted. Containers will by default be able to encode java primitive types and their object equivalents, otherwise the developer must have provided an encoder for the object type in the endpoint configuration. A developer-provided encoder for a Java primitive type overrides the container default encoder.- Parameters:
data
- the object to be sent.- Throws:
IOException
- if there is a communication error sending the message object.EncodeException
- if there was a problem encoding the message object into the form of a native websocket message.IllegalArgumentException
- if the data parameter isnull
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/websocket/RemoteEndpoint.Basic.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.