src/java.net.http/share/classes/java/net/http/WebSocket.java
branchhttp-client-branch
changeset 56151 eae2b2d7fe52
parent 56089 42208b2f224e
child 56156 336393c75a93
equal deleted inserted replaced
56143:11e32a62803d 56151:eae2b2d7fe52
    24  */
    24  */
    25 
    25 
    26 package java.net.http;
    26 package java.net.http;
    27 
    27 
    28 import java.io.IOException;
    28 import java.io.IOException;
       
    29 import java.net.ProtocolException;
    29 import java.net.URI;
    30 import java.net.URI;
    30 import java.nio.ByteBuffer;
    31 import java.nio.ByteBuffer;
    31 import java.time.Duration;
    32 import java.time.Duration;
    32 import java.util.concurrent.CompletableFuture;
    33 import java.util.concurrent.CompletableFuture;
    33 import java.util.concurrent.CompletionStage;
    34 import java.util.concurrent.CompletionStage;
   211      * <p> A {@code WebSocket} invokes methods on its listener when it receives
   212      * <p> A {@code WebSocket} invokes methods on its listener when it receives
   212      * messages or encounters events. The invoking {@code WebSocket} is passed
   213      * messages or encounters events. The invoking {@code WebSocket} is passed
   213      * as an argument to {@code Listener}'s methods. A {@code WebSocket} invokes
   214      * as an argument to {@code Listener}'s methods. A {@code WebSocket} invokes
   214      * methods on its listener in a thread-safe manner.
   215      * methods on its listener in a thread-safe manner.
   215      *
   216      *
       
   217      * <p> Messages received by the {@code Listener} conform to the WebSocket
       
   218      * Protocol, otherwise {@code onError} with a {@link ProtocolException} is
       
   219      * invoked.
       
   220      *
   216      * <p> Unless otherwise stated if a listener's method throws an exception or
   221      * <p> Unless otherwise stated if a listener's method throws an exception or
   217      * a {@code CompletionStage} returned from a method completes exceptionally,
   222      * a {@code CompletionStage} returned from a method completes exceptionally,
   218      * the {@code WebSocket} will invoke {@code onError} with this exception.
   223      * the {@code WebSocket} will invoke {@code onError} with this exception.
   219      *
   224      *
   220      * <p> If a listener's method returns {@code null} rather than a
   225      * <p> If a listener's method returns {@code null} rather than a
   327         }
   332         }
   328 
   333 
   329         /**
   334         /**
   330          * A Ping message has been received.
   335          * A Ping message has been received.
   331          *
   336          *
   332          * <p> The message consists of not more than {@code 125} bytes from
   337          * <p> As guaranteed by the WebSocket Protocol, the message consists of
   333          * the buffer's position to its limit.
   338          * not more than {@code 125} bytes. These bytes are located from the
       
   339          * buffer's position to its limit.
   334          *
   340          *
   335          * <p> Return a {@code CompletionStage} which will be used by the
   341          * <p> Return a {@code CompletionStage} which will be used by the
   336          * {@code WebSocket} as a signal it may reclaim the
   342          * {@code WebSocket} as a signal it may reclaim the
   337          * {@code ByteBuffer}. Do not access the {@code ByteBuffer} after
   343          * {@code ByteBuffer}. Do not access the {@code ByteBuffer} after
   338          * this {@ode CompletionStage} has completed.
   344          * this {@ode CompletionStage} has completed.
   360         }
   366         }
   361 
   367 
   362         /**
   368         /**
   363          * A Pong message has been received.
   369          * A Pong message has been received.
   364          *
   370          *
   365          * <p> The message consists of not more than {@code 125} bytes from
   371          * <p> As guaranteed by the WebSocket Protocol, the message consists of
   366          * the buffer's position to its limit.
   372          * not more than {@code 125} bytes. These bytes are located from the
       
   373          * buffer's position to its limit.
   367          *
   374          *
   368          * <p> Return a {@code CompletionStage} which will be used by the
   375          * <p> Return a {@code CompletionStage} which will be used by the
   369          * {@code WebSocket} as a signal it may reclaim the
   376          * {@code WebSocket} as a signal it may reclaim the
   370          * {@code ByteBuffer}. Do not access the {@code ByteBuffer} after
   377          * {@code ByteBuffer}. Do not access the {@code ByteBuffer} after
   371          * this {@ode CompletionStage} has completed.
   378          * this {@ode CompletionStage} has completed.