javax.websocket

Interface RemoteEndpoint

  • All Known Subinterfaces:
    RemoteEndpoint.Async, RemoteEndpoint.Basic

    public interface RemoteEndpoint
    The RemoteEndpoint object is supplied by the container and represents the 'other end' or peer of the Web Socket conversation. Instances of the RemoteEndpoint are obtained from the Session using Session.getBasicRemote() or Session.getAsyncRemote(). Objects of this kind include numerous ways to send web socket messages. There are two kinds of RemoteEndpoint objects: RemoteEndpoint.Basic for synchronous sending of websocket messages, and RemoteEndpoint.Async for sending messages asynchronously.

    There is no guarantee of the successful delivery of a web socket message to the peer, but if the action of sending a message causes an error known to the container, the API throws it. RemoteEndpoints include a variety of ways to send messages: by whole message, in parts, and in various data formats including websocket pings and pongs.

    Implementations may or may not support batching of messages. More detail of the expected semantics of implementations that do support batching are laid out in setBatchingAllowed(boolean).

    Note: Implementations may choose their own schemes for sending large messages in smaller parts. These schemes may or may not bear a relationship to the underlying websocket dataframes in which the message is ultimately sent on the wire.

    If the underlying connection is closed and methods on the RemoteEndpoint are attempted to be called, they will result in an error being generated. For the methods that send messages, this will be an IOException, for the methods that alter configuration of the endpoint, this will be runtime IllegalArgumentExceptions.

    Author:
    dannycoward
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void flushBatch()
      This method is only used when batching is allowed for this RemoteEndpint.
      boolean getBatchingAllowed()
      Return whether the implementation is allowed to batch outgoing messages before sending.
      void sendPing(ByteBuffer applicationData)
      Send a Ping message containing the given application data to the remote endpoint.
      void sendPong(ByteBuffer applicationData)
      Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.
      void setBatchingAllowed(boolean allowed)
      Indicate to the implementation that it is allowed to batch outgoing messages before sending.

      Erste Seite von API Java Inhaltsverzeichnis Haut

    • Method Detail

      • setBatchingAllowed

        void setBatchingAllowed(boolean allowed)
                         throws IOException
        Indicate to the implementation that it is allowed to batch outgoing messages before sending. Not all implementations support batching of outgoing messages. The default mode for RemoteEndpoints is false. If the developer has indicated that batching of outgoing messages is permitted, then the developer must call flushBatch() in order to be sure that all the messages passed into the send methods of this RemoteEndpoint are sent. When batching is allowed, the implementations send operations are considered to have completed if the message has been written to the local batch, in the case when there is still room in the batch for the message, and are considered to have completed if the batch has been send to the peer and the remainder written to the new batch, in the case when writing the message causes the batch to need to be sent. The blocking and asynchronous send methods use this notion of completion in order to complete blocking calls, notify SendHandlers and complete Futures respectively. When batching is allowed, if the developer has called send methods on this RemoteEndpoint without calling flushBatch(), then the implementation may not have sent all the messages the developer has asked to be sent. If the parameter value is false and the implementation has a batch of unsent messages, then the implementation must immediately send the batch of unsent messages.
        Parameters:
        allowed - whether the implementation is allowed to batch messages.
        Throws:
        IOException - if batching is being disabled and there are unsent messages this error may be thrown as the implementation sends the batch of unsent messages if there is a problem.
      • getBatchingAllowed

        boolean getBatchingAllowed()
        Return whether the implementation is allowed to batch outgoing messages before sending. The default mode for RemoteEndpoints is false. The value may be changed by calling setBatchingAllowed.
      • flushBatch

        void flushBatch()
                 throws IOException
        This method is only used when batching is allowed for this RemoteEndpint. Calling this method forces the implementation to send any unsent messages it has been batching.
        Throws:
        IOException
      • sendPing

        void sendPing(ByteBuffer applicationData)
               throws IOException,
                      IllegalArgumentException
        Send a Ping message containing the given application data to the remote endpoint. The corresponding Pong message may be picked up using the MessageHandler.Pong handler.
        Parameters:
        applicationData - the data to be carried in the ping request.
        Throws:
        IOException - if the ping failed to be sent
        IllegalArgumentException - if the applicationData exceeds the maximum allowed payload of 125 bytes
      • sendPong

        void sendPong(ByteBuffer applicationData)
               throws IOException,
                      IllegalArgumentException
        Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.
        Parameters:
        applicationData - the application data to be carried in the pong response.
        Throws:
        IOException - if the pong failed to be sent
        IllegalArgumentException - if the applicationData exceeds the maximum allowed payload of 125 bytes

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.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

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com, RemoteEndpoint (Java(TM) EE 7 Specification APIs)

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.