Trait

sttp.ws

WebSocket

Related Doc: package ws

Permalink

trait WebSocket[F[_]] extends AnyRef

The send* and receive* methods may result in a failed effect, with either one of WebSocketException exceptions, or a backend-specific exception. Specifically, they will fail with WebSocketClosed if the web socket is closed.

See the either and eitherClose method to lift web socket closed events to the value level.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. WebSocket
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def isOpen(): F[Boolean]

    Permalink
  2. implicit abstract def monad: MonadError[F]

    Permalink
  3. abstract def receive(): F[WebSocketFrame]

    Permalink

    Receive the next frame from the web socket.

    Receive the next frame from the web socket. This can be a data frame, or a control frame including WebSocketFrame.Close. After receiving a close frame, no further interactions with the web socket should happen.

    However, not all implementations expose the close frame, and web sockets might also get closed without the proper close frame exchange. In such cases, as well as when invoking receive/send after receiving a close frame, this effect will fail with the WebSocketClosed exception.

  4. abstract def send(f: WebSocketFrame, isContinuation: Boolean = false): F[Unit]

    Permalink
  5. abstract def upgradeHeaders: Headers

    Permalink

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  6. def close(): F[Unit]

    Permalink

    Idempotent when used sequentially.

  7. def either[T](f: ⇒ F[T]): F[Either[Option[Close], T]]

    Permalink

    Returns an effect computing a:

    Returns an effect computing a:

    - Left if the web socket is closed - optionally with the received close frame (if available). - Right with the original result otherwise.

    Will never fail with a WebSocketClosed.

    f

    The effect describing web socket interactions.

  8. def eitherClose[T](f: ⇒ F[T]): F[Either[Close, T]]

    Permalink

    Extracts the received close frame (if available) as the left side of an either, or returns the original result on the right.

    Extracts the received close frame (if available) as the left side of an either, or returns the original result on the right.

    Will fail with WebSocketClosed if the web socket is closed, but no close frame is available.

    f

    The effect describing web socket interactions.

  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  17. def receiveBinary(pongOnPing: Boolean): F[Array[Byte]]

    Permalink

    Receive a single binary message (which might come from multiple, fragmented frames).

    Receive a single binary message (which might come from multiple, fragmented frames). Ignores non-binary frames and returns combined results. Will fail with WebSocketClosed if the web socket is closed, or if a close frame is received.

    pongOnPing

    Should a WebSocketFrame.Pong be sent when a WebSocketFrame.Ping is received.

  18. def receiveBinaryFrame(pongOnPing: Boolean = true): F[Binary]

    Permalink

    Receive a single binary data frame, ignoring others.

    Receive a single binary data frame, ignoring others. The frame might be a fragment. To receive whole messages, use receiveBinary. Will fail with WebSocketClosed if the web socket is closed, or if a close frame is received.

    pongOnPing

    Should a WebSocketFrame.Pong be sent when a WebSocketFrame.Ping is received.

  19. def receiveDataFrame(pongOnPing: Boolean = true): F[Data[_]]

    Permalink

    Receive a single data frame, ignoring others.

    Receive a single data frame, ignoring others. The frame might be a fragment. Will fail with WebSocketClosed if the web socket is closed, or if a close frame is received.

    pongOnPing

    Should a WebSocketFrame.Pong be sent when a WebSocketFrame.Ping is received.

  20. def receiveText(pongOnPing: Boolean = true): F[String]

    Permalink

    Receive a single text message (which might come from multiple, fragmented frames).

    Receive a single text message (which might come from multiple, fragmented frames). Ignores non-text frames and returns combined results. Will fail with WebSocketClosed if the web socket is closed, or if a close frame is received.

    pongOnPing

    Should a WebSocketFrame.Pong be sent when a WebSocketFrame.Ping is received.

  21. def receiveTextFrame(pongOnPing: Boolean = true): F[Text]

    Permalink

    Receive a single text data frame, ignoring others.

    Receive a single text data frame, ignoring others. The frame might be a fragment. To receive whole messages, use receiveText. Will fail with WebSocketClosed if the web socket is closed, or if a close frame is received.

    pongOnPing

    Should a WebSocketFrame.Pong be sent when a WebSocketFrame.Ping is received.

  22. def sendBinary(payload: Array[Byte]): F[Unit]

    Permalink
  23. def sendText(payload: String): F[Unit]

    Permalink
  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Ungrouped