Beispiel #1
0
 /**
  * Closes the WebSocket connection or connection attempt, if any. If the connection is already
  * {@link #CLOSED}, this method does nothing.
  *
  * @param code A numeric value indicating the status code explaining why the connection is being
  *     closed
  * @param reason A human-readable string explaining why the connection is closing
  */
 @JsxFunction
 public void close(final Object code, final Object reason) {
   if (incomingConnection_ != null) {
     incomingConnection_.close();
   }
   if (outgoingConnection_ != null) {
     outgoingConnection_.close();
   }
 }
Beispiel #2
0
 /**
  * Transmits data to the server over the WebSocket connection.
  *
  * @param content the body of the message being sent with the request
  */
 @JsxFunction
 public void send(final Object content) {
   try {
     if (content instanceof String) {
       outgoingConnection_.sendMessage(content.toString());
     } else {
       throw new IllegalStateException(
           "Not Yet Implemented: WebSocket.send() was used to send non-string value");
     }
   } catch (final Exception e) {
     LOG.error(e);
   }
 }