WebSocketStub

class WebSocketStub[S](initialResponses: List[Try[WebSocketFrame]], initialState: S, makeNewResponses: (S, WebSocketFrame) => (S, List[Try[WebSocketFrame]]))

A stub for websockets that uses a queue of frames which are returned when the client calls WebSocket.receive.

New messages can be added to queue in reaction to WebSocket.send being invoked, by specifying the behavior using one of the thenRespond variants.

For more complex cases, please provide your own implementation of WebSocket.

Companion:
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def build[F[_]](implicit m: MonadError[F]): WebSocket[F]
def thenRespond(addReceived: WebSocketFrame => List[WebSocketFrame]): WebSocketStub[Unit]

Creates a stub that has the same initial receive frames, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

Creates a stub that has the same initial receive frames, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

def thenRespondS[S2](initial: S2)(onSend: (S2, WebSocketFrame) => (S2, List[WebSocketFrame])): WebSocketStub[S2]

Creates a stub that has the same initial responses, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

Creates a stub that has the same initial responses, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

More powerful version of thenRespond, as the given function can additionally use state and implement stateful logic for computing response messages.

def thenRespondWith(addReceived: WebSocketFrame => List[Try[WebSocketFrame]]): WebSocketStub[Unit]

Creates a stub that has the same initial receive frames, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

Creates a stub that has the same initial receive frames, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

More powerful version of thenRespond which allows receiving to fail with an exception.

def thenRespondWithS[S2](initial: S2)(onSend: (S2, WebSocketFrame) => (S2, List[Try[WebSocketFrame]])): WebSocketStub[S2]

Creates a stub that has the same initial responses, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

Creates a stub that has the same initial responses, but replaces the function that adds responses to be received in reaction to WebSocket.send being invoked.

More powerful version of:

  • thenRespond, as the given function can additionally use state and implement stateful logic for computing response messages.
  • thenRespondS which allows receiving to fail with an exception.