2121import static java .util .Objects .requireNonNull ;
2222
2323import java .io .Closeable ;
24+ import java .nio .channels .ClosedChannelException ;
2425import java .util .Map ;
2526import java .util .Optional ;
2627import java .util .Set ;
@@ -585,6 +586,13 @@ default void close() {
585586 close (NORMAL );
586587 }
587588
589+ /**
590+ * True if the websocket is still open.
591+ *
592+ * @return True if the websocket is still open.
593+ */
594+ boolean isOpen ();
595+
588596 /**
589597 * Gracefully closes the connection, after sending a description message
590598 *
@@ -612,6 +620,8 @@ default void close() {
612620 /**
613621 * Send data through the connection.
614622 *
623+ * If the web socket is closed this method throw an {@link Err} with {@link #NORMAL} close status.
624+ *
615625 * @param data Data to send.
616626 * @throws Exception If something goes wrong.
617627 */
@@ -622,6 +632,8 @@ default void send(final Object data) throws Exception {
622632 /**
623633 * Send data through the connection.
624634 *
635+ * If the web socket is closed this method throw an {@link Err} with {@link #NORMAL} close status.
636+ *
625637 * @param data Data to send.
626638 * @param success A success callback.
627639 * @throws Exception If something goes wrong.
@@ -633,24 +645,26 @@ default void send(final Object data, final SuccessCallback success) throws Excep
633645 /**
634646 * Send data through the connection.
635647 *
648+ * If the web socket is closed this method throw an {@link Err} with {@link #NORMAL} close status.
649+ *
636650 * @param data Data to send.
637651 * @param err An err callback.
638652 * @throws Exception If something goes wrong.
639653 */
640- default void send (final Object data , final ErrCallback err )
641- throws Exception {
654+ default void send (final Object data , final ErrCallback err ) throws Exception {
642655 send (data , SUCCESS , err );
643656 }
644657
645658 /**
646659 * Send data through the connection.
647660 *
661+ * If the web socket is closed this method throw an {@link Err} with {@link #NORMAL} close status.
662+ *
648663 * @param data Data to send.
649664 * @param success A success callback.
650665 * @param err An err callback.
651666 * @throws Exception If something goes wrong.
652667 */
653- void send (Object data , SuccessCallback success , ErrCallback err )
654- throws Exception ;
668+ void send (Object data , SuccessCallback success , ErrCallback err ) throws Exception ;
655669
656670}
0 commit comments